X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=blkiomon.c;h=f8b0c9dec00c8f221677da65ee1dd3469baf1d5e;hb=a61c06774d03fb768fa9fb021e94599822848c8a;hp=b53dfd947ca823ebf349a68eb3a743e4c52e7ab3;hpb=29ec9a38dabc610005c5b8d11dba2a0824117c97;p=blktrace.git diff --git a/blkiomon.c b/blkiomon.c index b53dfd9..f8b0c9d 100644 --- a/blkiomon.c +++ b/blkiomon.c @@ -71,7 +71,7 @@ struct output { int pipe; }; -static char blkiomon_version[] = "0.2"; +static char blkiomon_version[] = "0.3"; static FILE *ifp; static int interval = -1; @@ -168,7 +168,7 @@ static struct dstat *blkiomon_alloc_dstat(void) return NULL; } - memset(dstat, 0, sizeof(*dstat)); + blkiomon_stat_init(&dstat->msg.stat); return dstat; } @@ -198,7 +198,7 @@ static struct dstat *blkiomon_find_dstat(struct rb_search *search, __u32 device) static struct dstat *blkiomon_get_dstat(__u32 device) { struct dstat *dstat; - struct rb_search search; + struct rb_search search = { 0, }; pthread_mutex_lock(&dstat_mutex); @@ -211,10 +211,6 @@ static struct dstat *blkiomon_get_dstat(__u32 device) goto out; dstat->msg.stat.device = device; - dstat->msg.stat.size_r.min = -1ULL; - dstat->msg.stat.size_w.min = -1ULL; - dstat->msg.stat.d2c_r.min = -1ULL; - dstat->msg.stat.d2c_w.min = -1ULL; rb_link_node(&dstat->node, search.parent, search.node_ptr); rb_insert_color(&dstat->node, &dstat_tree[dstat_curr]); @@ -316,6 +312,7 @@ static int blkiomon_account(struct blk_io_trace *bit_d, struct blkiomon_stat *p; __u64 d2c = (bit_c->time - bit_d->time) / 1000; /* ns -> us */ __u32 size = bit_d->bytes; + __u64 thrput = size * 1000 / d2c; dstat = blkiomon_get_dstat(bit_d->device); if (!dstat) @@ -323,9 +320,11 @@ static int blkiomon_account(struct blk_io_trace *bit_d, p = &dstat->msg.stat; if (BLK_DATADIR(bit_c->action) & BLK_TC_READ) { + minmax_account(&p->thrput_r, thrput); minmax_account(&p->size_r, size); minmax_account(&p->d2c_r, d2c); } else if (BLK_DATADIR(bit_c->action) & BLK_TC_WRITE) { + minmax_account(&p->thrput_w, thrput); minmax_account(&p->size_w, size); minmax_account(&p->d2c_w, d2c); } else @@ -600,8 +599,9 @@ static char usage_str[] = "\n\nblkiomon " \ "-I | --interval=\n" \ "[ -h | --human-readable= ]\n" \ "[ -b | --binary= ]\n" \ + "[ -d | --dump-lldd= ]\n" \ "[ -D | --debug= ]\n" \ - "[ -Q | --msg-queue-name=]\n" \ + "[ -Q | --msg-queue=]\n" \ "[ -q | --msg-queue-id=]\n" \ "[ -m | --msg-id=]\n" \ "[ -V | --version ]\n\n" \