X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=t%2Fbtrace2fio.c;h=4cdb38d10d3ec8c53ee265787124b70a76893556;hb=8d7632aa5a5a5c866ff2872319056df4ac2541ed;hp=fc1e4c786df848589272c73600b13840f489d29f;hpb=ccfcf5bfc6a37195b5d9bf7c676d92631cd6cfc5;p=fio.git diff --git a/t/btrace2fio.c b/t/btrace2fio.c index fc1e4c78..4cdb38d1 100644 --- a/t/btrace2fio.c +++ b/t/btrace2fio.c @@ -12,7 +12,7 @@ #include "../blktrace_api.h" #include "../os/os.h" #include "../log.h" -#include "../lib/linux-dev-lookup.h" +#include "../oslib/linux-dev-lookup.h" #define TRACE_FIFO_SIZE 8192 @@ -24,6 +24,9 @@ static unsigned int max_depth = 256; static int output_ascii = 1; static char *filename; +static char **add_opts; +static int n_add_opts; + /* * Collapse defaults */ @@ -59,7 +62,7 @@ struct btrace_out { uint64_t first_ttime[DDIR_RWDIR_CNT]; uint64_t last_ttime[DDIR_RWDIR_CNT]; - uint64_t kb[DDIR_RWDIR_CNT]; + uint64_t kib[DDIR_RWDIR_CNT]; uint64_t start_delay; }; @@ -403,7 +406,7 @@ static int handle_trace(struct blk_io_trace *t, struct btrace_pid *p) i = inflight_find(t->sector + (t->bytes >> 9)); if (i) { - i->p->o.kb[t_to_rwdir(t)] += (t->bytes >> 10); + i->p->o.kib[t_to_rwdir(t)] += (t->bytes >> 10); i->p->o.complete_seen = 1; inflight_remove(i); } @@ -553,7 +556,7 @@ static int bs_cmp(const void *ba, const void *bb) return bsb->nr - bsa->nr; } -static unsigned long o_to_kb_rate(struct btrace_out *o, int rw) +static unsigned long o_to_kib_rate(struct btrace_out *o, int rw) { uint64_t usec = (o->last_ttime[rw] - o->first_ttime[rw]) / 1000ULL; uint64_t val; @@ -565,7 +568,7 @@ static unsigned long o_to_kb_rate(struct btrace_out *o, int rw) if (!usec) return 0; - val = o->kb[rw] * 1000ULL; + val = o->kib[rw] * 1000ULL; return val / usec; } @@ -620,7 +623,7 @@ static void __output_p_ascii(struct btrace_pid *p, unsigned long *ios) printf("\tmerges: %lu (perc=%3.2f%%)\n", o->merges[i], perc); perc = ((float) o->seq[i] * 100.0) / (float) o->ios[i]; printf("\tseq: %lu (perc=%3.2f%%)\n", (unsigned long) o->seq[i], perc); - printf("\trate: %lu KB/sec\n", o_to_kb_rate(o, i)); + printf("\trate: %lu KiB/sec\n", o_to_kib_rate(o, i)); for (j = 0; j < o->nr_bs[i]; j++) { struct bs *bs = &o->bs[i][j]; @@ -743,7 +746,7 @@ static int __output_p_fio(struct btrace_pid *p, unsigned long *ios) for (i = 0; i < DDIR_RWDIR_CNT; i++) { unsigned long rate; - rate = o_to_kb_rate(o, i); + rate = o_to_kib_rate(o, i); if (i) printf(","); if (rate) @@ -752,6 +755,10 @@ static int __output_p_fio(struct btrace_pid *p, unsigned long *ios) printf("\n"); } + if (n_add_opts) + for (i = 0; i < n_add_opts; i++) + printf("%s\n", add_opts[i]); + printf("\n"); return 0; } @@ -803,7 +810,7 @@ static int prune_entry(struct btrace_out *o) for (i = 0; i < DDIR_RWDIR_CNT; i++) { unsigned long this_rate; - this_rate = o_to_kb_rate(o, i); + this_rate = o_to_kib_rate(o, i); if (this_rate < rate_threshold) { remove_ddir(o, i); this_rate = 0; @@ -919,7 +926,7 @@ static int merge_entries(struct btrace_pid *pida, struct btrace_pid *pidb) oa->ios[i] += ob->ios[i]; oa->merges[i] += ob->merges[i]; oa->seq[i] += ob->seq[i]; - oa->kb[i] += ob->kb[i]; + oa->kib[i] += ob->kib[i]; oa->first_ttime[i] = min(oa->first_ttime[i], ob->first_ttime[i]); oa->last_ttime[i] = max(oa->last_ttime[i], ob->last_ttime[i]); merge_bs(&oa->bs[i], &oa->nr_bs[i], ob->bs[i], ob->nr_bs[i]); @@ -930,14 +937,14 @@ static int merge_entries(struct btrace_pid *pida, struct btrace_pid *pidb) return 1; } -static void check_merges(struct btrace_pid *p, struct flist_head *pid_list) +static void check_merges(struct btrace_pid *p, struct flist_head *pidlist) { struct flist_head *e, *tmp; if (p->ignore) return; - flist_for_each_safe(e, tmp, pid_list) { + flist_for_each_safe(e, tmp, pidlist) { struct btrace_pid *pidb; pidb = flist_entry(e, struct btrace_pid, pid_list); @@ -1014,12 +1021,13 @@ static int usage(char *argv[]) log_err("\t-n\tNumber IOS threshold to ignore task\n"); log_err("\t-f\tFio job file output\n"); log_err("\t-d\tUse this file/device for replay\n"); - log_err("\t-r\tIgnore jobs with less than this KB/sec rate\n"); + log_err("\t-r\tIgnore jobs with less than this KiB/sec rate\n"); log_err("\t-R\tSet rate in fio job (def=%u)\n", set_rate); log_err("\t-D\tCap queue depth at this value (def=%u)\n", max_depth); log_err("\t-c\tCollapse \"identical\" jobs (def=%u)\n", collapse_entries); log_err("\t-u\tDepth difference for collapse (def=%u)\n", depth_diff); log_err("\t-x\tRandom difference for collapse (def=%u)\n", random_diff); + log_err("\t-a\tAdditional fio option to add to job file\n"); return 1; } @@ -1075,7 +1083,7 @@ int main(int argc, char *argv[]) if (argc < 2) return usage(argv); - while ((c = getopt(argc, argv, "t:n:fd:r:RD:c:u:x:")) != -1) { + while ((c = getopt(argc, argv, "t:n:fd:r:RD:c:u:x:a:")) != -1) { switch (c) { case 'R': set_rate = 1; @@ -1107,6 +1115,11 @@ int main(int argc, char *argv[]) case 'x': random_diff = atoi(optarg); break; + case 'a': + add_opts = realloc(add_opts, (n_add_opts + 1) * sizeof(char *)); + add_opts[n_add_opts] = strdup(optarg); + n_add_opts++; + break; case '?': default: return usage(argv);