Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions btstats.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <string.h>
#include <stdio.h>
#include <getopt.h>
#include <stdbool.h>

#include <blktrace_api.h>
#include <blktrace.h>
Expand All @@ -21,7 +22,7 @@ struct time_range {

struct args {
GHashTable *devs_ranges;
gboolean total;
bool total;
char *d2c_det;
unsigned trc_rdr;
char *i2c_oio;
Expand Down Expand Up @@ -189,7 +190,7 @@ void handle_args(int argc, char **argv, struct args *a)
file = optarg;
break;
case 't':
a->total = TRUE;
a->total = true;
break;
case 'd':
a->d2c_det = optarg;
Expand Down
9 changes: 5 additions & 4 deletions statplug/d2c.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <assert.h>
#include <stdio.h>
#include <stdbool.h>

#include <plugins.h>
#include <blktrace_api.h>
Expand Down Expand Up @@ -42,7 +43,7 @@ static void D(struct blk_io_trace *t, void *data)
}
}

static void __account_reqs(struct d2c_data *d2c, gboolean finished)
static void __account_reqs(struct d2c_data *d2c, bool finished)
{
d2c->outstanding--;
if (d2c->outstanding == 0 || finished) {
Expand Down Expand Up @@ -124,7 +125,7 @@ static void C(struct blk_io_trace *t, void *data)
g_tree_remove(d2c->prospect_ds, &dtrace->sector);
g_free(dtrace);

__account_reqs(d2c, FALSE);
__account_reqs(d2c, false);
}
}

Expand All @@ -141,7 +142,7 @@ static void R(struct blk_io_trace *t, void *data)
g_tree_remove(d2c->prospect_ds, &dtrace->sector);
g_free(dtrace);

__account_reqs(d2c, FALSE);
__account_reqs(d2c, false);
}
}

Expand All @@ -157,7 +158,7 @@ void d2c_print_results(const void *data)
{
DECL_ASSIGN_D2C(d2c, data);

__account_reqs(d2c, TRUE);
__account_reqs(d2c, true);

if (d2c->d2ctime > 0) {
double t_time_msec = ((double)d2c->d2ctime) / 1e6;
Expand Down
25 changes: 17 additions & 8 deletions statplug/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <glib.h>
#include <stdio.h>
#include <assert.h>
#include <stdbool.h>
#include <inttypes.h>
#include <float.h>

Expand Down Expand Up @@ -76,13 +77,21 @@ static void init_oio_data(struct oio_data *oio, int n)
}
}

static gboolean add_to_matrix(__u64 *__unused, struct blk_io_trace *t,
struct i2c_data *i2c)
static bool add_to_matrix_impl(gpointer __unused, gpointer t, gpointer i2c_arg)
{
gsl_histogram_increment(i2c->oio[i2c->outstanding].op[IS_WRITE(t)],
(double)(t->bytes / BLK_SIZE));
struct i2c_data *i2c = (struct i2c_data *)i2c_arg;
struct blk_io_trace *trace = (struct blk_io_trace *)t;

return FALSE;
gsl_histogram_increment(i2c->oio[i2c->outstanding].op[IS_WRITE(trace)],
(double)(trace->bytes / BLK_SIZE));

return false;
}

static gboolean add_to_matrix_wrapper(gpointer key, gpointer value,
gpointer data)
{
return add_to_matrix_impl(key, value, data) ? TRUE : FALSE;
}

static void oio_change(struct i2c_data *i2c, struct blk_io_trace *t, int inc)
Expand All @@ -108,7 +117,7 @@ static void oio_change(struct i2c_data *i2c, struct blk_io_trace *t, int inc)
}
i2c->maxouts = MAX(i2c->maxouts, i2c->outstanding);

g_tree_foreach(i2c->is, (GTraverseFunc)add_to_matrix, i2c);
g_tree_foreach(i2c->is, add_to_matrix_wrapper, i2c);

write_outs(i2c, t);
}
Expand All @@ -120,7 +129,7 @@ static void C(struct blk_io_trace *t, void *data)
if (g_tree_lookup(i2c->is, &t->sector) != NULL) {
g_tree_remove(i2c->is, &t->sector);

oio_change(i2c, t, FALSE);
oio_change(i2c, t, false);
}
}

Expand All @@ -132,7 +141,7 @@ static void I(struct blk_io_trace *t, void *data)
DECL_DUP(struct blk_io_trace, new_t, t);
g_tree_insert(i2c->is, &new_t->sector, new_t);

oio_change(i2c, t, TRUE);
oio_change(i2c, t, true);
}
}

Expand Down
7 changes: 4 additions & 3 deletions statplug/pluging.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <asm/types.h>
#include <stdio.h>
#include <stdbool.h>

#include <blktrace_api.h>
#include <blktrace.h>
Expand All @@ -15,7 +16,7 @@ struct pluging_data {
__u64 nplugs;

__u64 plug_time;
gboolean plugged;
bool plugged;
};

static void P(struct blk_io_trace *t, void *data)
Expand All @@ -24,7 +25,7 @@ static void P(struct blk_io_trace *t, void *data)

if (!plug->plugged) {
plug->plug_time = t->time;
plug->plugged = TRUE;
plug->plugged = true;
}
}

Expand All @@ -41,7 +42,7 @@ static void U(struct blk_io_trace *t, void *data)
plug->min = MIN(plug->min, time);
plug->max = MAX(plug->max, time);

plug->plugged = FALSE;
plug->plugged = false;
plug->plug_time = 0;
}
}
Expand Down
14 changes: 10 additions & 4 deletions statplug/q2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <glib.h>
#include <stdio.h>
#include <assert.h>
#include <stdbool.h>

#include <blktrace_api.h>
#include <blktrace.h>
Expand Down Expand Up @@ -36,7 +37,7 @@ struct proc_q_arg {
struct q2c_data *q2c;
};

static gboolean proc_q(gpointer __unused, gpointer tp, gpointer pqap)
static bool proc_q_impl(gpointer __unused, gpointer tp, gpointer pqap)
{
struct blk_io_trace *t = (struct blk_io_trace *)tp;
struct proc_q_arg *pqa = (struct proc_q_arg *)pqap;
Expand All @@ -49,12 +50,17 @@ static gboolean proc_q(gpointer __unused, gpointer tp, gpointer pqap)
pqa->q2c->start = this_ts;
pqa->q2c->processed++;
pqa->q2c->outstanding--;
return TRUE;
return true;
} else {
return FALSE;
return false;
}
}

static gboolean proc_q_wrapper(gpointer key, gpointer value, gpointer data)
{
return proc_q_impl(key, value, data) ? TRUE : FALSE;
}

static void restart_ongoing(struct q2c_data *q2c)
{
/* restart ongoing period */
Expand All @@ -71,7 +77,7 @@ static void C(struct blk_io_trace *t, void *data)
if (t->time > q2c->end)
q2c->end = t->time;

g_hash_table_foreach_remove(q2c->qs, proc_q, &pqa);
g_hash_table_foreach_remove(q2c->qs, proc_q_wrapper, &pqa);
if (q2c->outstanding == 0 && q2c->processed > 0) {
q2c->q2c_time += q2c->end - q2c->start;
restart_ongoing(q2c);
Expand Down
11 changes: 6 additions & 5 deletions trace_reader/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <glib.h>
#include <utils.h>
#include <stdbool.h>
#include <unistd.h>
#include <string.h>
#include <libgen.h>
Expand Down Expand Up @@ -52,7 +53,7 @@ void correct_time(gpointer data, gpointer dt_arg)
tf->t.time -= dt->genesis;
}

gboolean not_real_event(struct blk_io_trace *t)
bool not_real_event(struct blk_io_trace *t)
{
return (t->action & BLK_TC_ACT(BLK_TC_NOTIFY)) ||
(t->action & BLK_TC_ACT(BLK_TC_DISCARD)) ||
Expand All @@ -66,7 +67,7 @@ void read_next(struct trace_file *tf, __u64 genesis)
do {
e = read(tf->fd, &tf->t, sizeof(struct blk_io_trace));
if (e == 0) {
tf->eof = TRUE;
tf->eof = true;
break;
} else if (e == -1 || e != sizeof(struct blk_io_trace)) {
perror_exit("Reading trace\n");
Expand Down Expand Up @@ -179,17 +180,17 @@ void trace_destroy(struct trace *dt)
g_free(dt);
}

gboolean trace_read_next(const struct trace *dt, struct blk_io_trace *t)
bool trace_read_next(const struct trace *dt, struct blk_io_trace *t)
{
struct trace_file *min = NULL;

g_slist_foreach(dt->files, min_time, &min);

if (!min)
return FALSE;
return false;
else {
*t = min->t;
read_next(min, dt->genesis);
return TRUE;
return true;
}
}
9 changes: 5 additions & 4 deletions trace_reader/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,30 @@

#include <blktrace_api.h>
#include <glib.h>
#include <stdbool.h>

struct trace_file {
struct blk_io_trace t;
int fd;
gboolean eof;
bool eof;
};

struct trace {
GSList *files;
__u64 genesis;
};

typedef gboolean (*trace_reader_t)(const struct trace *, struct blk_io_trace *);
typedef bool (*trace_reader_t)(const struct trace *, struct blk_io_trace *);

/* constructor and destructor */
struct trace *trace_create(const char *dev);
void trace_destroy(struct trace *dt);

/* default trace reader */
gboolean trace_read_next(const struct trace *dt, struct blk_io_trace *t);
bool trace_read_next(const struct trace *dt, struct blk_io_trace *t);

/* reader for devices with ata_piix controller */
gboolean trace_ata_piix_read_next(const struct trace *dt,
bool trace_ata_piix_read_next(const struct trace *dt,
struct blk_io_trace *t);

/*
Expand Down
17 changes: 9 additions & 8 deletions trace_reader/trace_ata_piix.c
Original file line number Diff line number Diff line change
@@ -1,42 +1,43 @@
#include <glib.h>
#include <assert.h>
#include <string.h>
#include <stdbool.h>

#include <trace.h>

#include <blktrace.h>
#include <blktrace_api.h>

static struct blk_io_trace at;
static gboolean send_p_d = FALSE;
static bool send_p_d = false;
static int out_reqs = 0;
static __u64 blks;

gboolean trace_ata_piix_read_next(const struct trace *dt,
bool trace_ata_piix_read_next(const struct trace *dt,
struct blk_io_trace *t)
{
gboolean r;
bool r;

if (send_p_d) {
/* if we have a pending D event,
* we first send this before the next one
*/
*t = at;
send_p_d = FALSE;
return TRUE;
send_p_d = false;
return true;
} else {
reread:
r = trace_read_next(dt, t);
blks = t_blks(t);

/* if the trace reach the end */
if (!r)
return FALSE;
return false;

switch (t->action & 0xffff) {
case __BLK_TA_COMPLETE:
if (out_reqs == 2) {
send_p_d = TRUE;
send_p_d = true;

/* setting the time to the next D
* to be the time of the complete (ns)
Expand Down Expand Up @@ -72,6 +73,6 @@ gboolean trace_ata_piix_read_next(const struct trace *dt,
out_reqs -= out_reqs > 0 ? 1 : 0;
break;
}
return TRUE;
return true;
}
}