diff options
-rw-r--r-- | btt/aqd.c | 6 | ||||
-rw-r--r-- | btt/bno_dump.c | 18 | ||||
-rw-r--r-- | btt/devs.c | 63 | ||||
-rw-r--r-- | btt/globals.h | 15 | ||||
-rw-r--r-- | btt/latency.c | 18 | ||||
-rw-r--r-- | btt/misc.c | 5 | ||||
-rw-r--r-- | btt/plat.c | 6 | ||||
-rw-r--r-- | btt/rstats.c | 14 | ||||
-rw-r--r-- | btt/seek.c | 8 | ||||
-rw-r--r-- | btt/unplug_hist.c | 15 |
10 files changed, 83 insertions, 85 deletions
@@ -29,7 +29,7 @@ struct aqd_info { int na; /* # active */ }; -void *aqd_alloc(char *str) +void *aqd_alloc(struct d_info *dip) { char *oname; struct aqd_info *ap; @@ -39,8 +39,8 @@ void *aqd_alloc(char *str) ap = malloc(sizeof(*ap)); ap->na = 0; - oname = malloc(strlen(aqd_name) + strlen(str) + 32); - sprintf(oname, "%s_%s.dat", aqd_name, str); + oname = malloc(strlen(aqd_name) + strlen(dip->dip_name) + 32); + sprintf(oname, "%s_%s_aqd.dat", aqd_name, dip->dip_name); if ((ap->fp = my_fopen(oname, "w")) == NULL) { perror(oname); return NULL; diff --git a/btt/bno_dump.c b/btt/bno_dump.c index 7365300..02f3811 100644 --- a/btt/bno_dump.c +++ b/btt/bno_dump.c @@ -24,17 +24,13 @@ struct bno_dump { FILE *rfp, *wfp, *cfp; }; -static FILE *bno_dump_open(__u32 device, char rwc) +static FILE *bno_dump_open(struct d_info *dip, char rwc) { FILE *fp; char *oname; - int mjr, mnr; - mjr = device >> MINORBITS; - mnr = device & ((1 << MINORBITS) - 1); - - oname = malloc(strlen(bno_dump_name) + 32); - sprintf(oname, "%s_%03d,%03d_%c.dat", bno_dump_name, mjr, mnr, rwc); + oname = malloc(strlen(bno_dump_name) + strlen(dip->dip_name) + 32); + sprintf(oname, "%s_%s_%c.dat", bno_dump_name, dip->dip_name, rwc); if ((fp = my_fopen(oname, "w")) == NULL) perror(oname); else @@ -48,16 +44,16 @@ static inline void bno_dump_write(FILE *fp, struct io *iop) (long long)BIT_START(iop), (long long)BIT_END(iop)); } -void *bno_dump_alloc(__u32 device) +void *bno_dump_alloc(struct d_info *dip) { struct bno_dump *bdp; if (bno_dump_name == NULL) return NULL; bdp = malloc(sizeof(*bdp)); - bdp->rfp = bno_dump_open(device, 'r'); - bdp->wfp = bno_dump_open(device, 'w'); - bdp->cfp = bno_dump_open(device, 'c'); + bdp->rfp = bno_dump_open(dip, 'r'); + bdp->wfp = bno_dump_open(dip, 'w'); + bdp->cfp = bno_dump_open(dip, 'c'); return bdp; } @@ -104,20 +104,13 @@ void dip_exit(void) } } -static inline char *mkhandle(char *str, __u32 device, char *post) +static inline FILE *open_pit(struct d_info *dip) { - int mjr = device >> MINORBITS; - int mnr = device & ((1 << MINORBITS) - 1); + FILE *fp; + char str[256]; - sprintf(str, "%03d,%03d%s", mjr, mnr, post); - return str; -} - -static inline FILE *open_pit(char *str) -{ - FILE *fp = my_fopen(str, "w"); - - if (fp == NULL) + sprintf(str, "%s_pit.dat", dip->dip_name); + if ((fp = my_fopen(str, "w")) == NULL) perror(str); return fp; @@ -128,38 +121,38 @@ struct d_info *dip_alloc(__u32 device, struct io *iop) struct d_info *dip = __dip_find(device); if (dip == NULL) { - char str[256]; - dip = malloc(sizeof(struct d_info)); memset(dip, 0, sizeof(*dip)); - dip->heads = dip_rb_mkhds(); - region_init(&dip->regions); dip->device = device; - dip->last_q = (__u64)-1; dip->devmap = dev_map_find(device); - dip->bno_dump_handle = bno_dump_alloc(device); - dip->up_hist_handle = unplug_hist_alloc(device); - dip->seek_handle = seeki_alloc(mkhandle(str, device, "_d2d")); - dip->q2q_handle = seeki_alloc(mkhandle(str, device, "_q2q")); - dip->aqd_handle = aqd_alloc(mkhandle(str, device, "_aqd")); - dip->q2d_plat_handle = - plat_alloc(mkhandle(str, device, "_q2d_plat")); - dip->q2c_plat_handle = - plat_alloc(mkhandle(str, device, "_q2c_plat")); - dip->d2c_plat_handle = - plat_alloc(mkhandle(str, device, "_d2c_plat")); - latency_alloc(dip); - list_add_tail(&dip->hash_head, &dev_heads[DEV_HASH(device)]); - list_add_tail(&dip->all_head, &all_devs); + dip->last_q = (__u64)-1; + dip->heads = dip_rb_mkhds(); + region_init(&dip->regions); dip->start_time = BIT_TIME(iop->t.time); dip->pre_culling = 1; - dip->rstat_handle = rstat_alloc(mkhandle(str, device, "")); + + mkhandle(dip, dip->dip_name, 256); + + latency_alloc(dip); + dip->aqd_handle = aqd_alloc(dip); + dip->bno_dump_handle = bno_dump_alloc(dip); + dip->up_hist_handle = unplug_hist_alloc(dip); + dip->seek_handle = seeki_alloc(dip, "_d2d"); + dip->q2q_handle = seeki_alloc(dip, "_q2q"); + dip->q2d_plat_handle = plat_alloc(dip, "_q2d"); + dip->q2c_plat_handle = plat_alloc(dip, "_q2c"); + dip->d2c_plat_handle = plat_alloc(dip, "_d2c"); + dip->rstat_handle = rstat_alloc(dip); + + if (per_io_trees) + dip->pit_fp = open_pit(dip); + if (output_all_data) dip->q2d_priv = q2d_alloc(); + + list_add_tail(&dip->hash_head, &dev_heads[DEV_HASH(device)]); + list_add_tail(&dip->all_head, &all_devs); n_devs++; - if (per_io_trees) - dip->pit_fp = open_pit(mkhandle(per_io_trees, - device, "_pit.dat")); } if (dip->pre_culling) { diff --git a/btt/globals.h b/btt/globals.h index 5235ec6..e7d910d 100644 --- a/btt/globals.h +++ b/btt/globals.h @@ -131,7 +131,7 @@ struct d_info { struct list_head all_head, hash_head; void *heads; struct region_info regions; - char *devmap; + char *devmap, dip_name[256]; void *q2q_handle, *seek_handle, *bno_dump_handle, *up_hist_handle; void *q2d_priv, *aqd_handle, *rstat_handle; void *q2d_plat_handle, *q2c_plat_handle, *d2c_plat_handle; @@ -192,7 +192,7 @@ void handle_args(int argc, char *argv[]); void clean_args(); /* aqd.c */ -void *aqd_alloc(char *str); +void *aqd_alloc(struct d_info *dip); void aqd_free(void *info); void aqd_clean(void); void aqd_issue(void *info, double ts); @@ -246,6 +246,7 @@ void latency_q2c(struct d_info *dip, __u64 tstamp, __u64 latency); void add_file(FILE *fp, char *oname); void add_buf(void *buf); char *make_dev_hdr(char *pad, size_t len, struct d_info *dip, int add_parens); +char *mkhandle(struct d_info *dip, char *str, size_t len); FILE *my_fopen(const char *path, const char *mode); int my_open(const char *path, int flags); void dbg_ping(void); @@ -269,13 +270,13 @@ void pip_foreach_out(void (*f)(struct p_info *, void *), void *arg); void pip_exit(void); /* bno_dump.c */ -void *bno_dump_alloc(__u32 device); +void *bno_dump_alloc(struct d_info *dip); void bno_dump_free(void *param); void bno_dump_add(void *handle, struct io *iop); void bno_dump_clean(void); /* plat.c */ -void *plat_alloc(char *str); +void *plat_alloc(struct d_info *dip, char *post); void plat_free(void *info); void plat_clean(void); void plat_x2c(void *info, __u64 ts, __u64 latency); @@ -291,14 +292,14 @@ int q2d_ok(void *priv); void q2d_acc(void *a1, void *a2); /* rstats.c */ -void *rstat_alloc(char *bn); +void *rstat_alloc(struct d_info *dip); void rstat_free(void *ptr); void rstat_add(void *ptr, double cur, unsigned long long nblks); int rstat_init(void); void rstat_exit(void); /* seek.c */ -void *seeki_alloc(char *str); +void *seeki_alloc(struct d_info *dip, char *post); void seeki_free(void *param); void seek_clean(void); void seeki_add(void *handle, struct io *iop); @@ -347,7 +348,7 @@ void trace_remap(struct io *a_iop); void trace_requeue(struct io *r_iop); /* unplug_hist.c */ -void *unplug_hist_alloc(__u32 device); +void *unplug_hist_alloc(struct d_info *dip); void unplug_hist_free(void *arg); void unplug_hist_add(struct io *u_iop); diff --git a/btt/latency.c b/btt/latency.c index e3ecc26..51e6881 100644 --- a/btt/latency.c +++ b/btt/latency.c @@ -26,18 +26,16 @@ static inline void latency_out(FILE *ofp, __u64 tstamp, __u64 latency) fprintf(ofp, "%lf %lf\n", TO_SEC(tstamp), TO_SEC(latency)); } -FILE *latency_open(__u32 device, char *name, char *post) +FILE *latency_open(struct d_info *dip, char *name, char *post) { FILE *fp = NULL; if (name) { - int mjr, mnr; - char oname[strlen(name) + 32]; + size_t tlen = strlen(name) + strlen(dip->dip_name) + + strlen(post) + 32; + char oname[tlen]; - mjr = device >> MINORBITS; - mnr = device & ((1 << MINORBITS) - 1); - - sprintf(oname, "%s_%03d,%03d_%s.dat", name, mjr, mnr, post); + sprintf(oname, "%s_%s_%s.dat", name, dip->dip_name, post); if ((fp = my_fopen(oname, "w")) == NULL) perror(oname); else @@ -49,9 +47,9 @@ FILE *latency_open(__u32 device, char *name, char *post) void latency_alloc(struct d_info *dip) { - dip->q2d_ofp = latency_open(dip->device, q2d_name, "q2d"); - dip->d2c_ofp = latency_open(dip->device, d2c_name, "d2c"); - dip->q2c_ofp = latency_open(dip->device, q2c_name, "q2c"); + dip->q2d_ofp = latency_open(dip, q2d_name, "q2d"); + dip->d2c_ofp = latency_open(dip, d2c_name, "d2c"); + dip->q2c_ofp = latency_open(dip, q2c_name, "q2c"); } void latency_q2d(struct d_info *dip, __u64 tstamp, __u64 latency) @@ -146,6 +146,11 @@ char *make_dev_hdr(char *pad, size_t len, struct d_info *dip, int add_parens) return pad; } +char *mkhandle(struct d_info *dip, char *str, size_t len) +{ + return make_dev_hdr(str, len, dip, 0); +} + FILE *my_fopen(const char *path, const char *mode) { FILE *fp; @@ -27,7 +27,7 @@ struct plat_info { double first_ts, last_ts, tl; }; -void *plat_alloc(char *str) +void *plat_alloc(struct d_info *dip, char *post) { char *oname; struct plat_info *pp; @@ -38,8 +38,8 @@ void *plat_alloc(char *str) pp->nl = 0; pp->first_ts = pp->last_ts = pp->tl = -1.0; - oname = malloc(strlen(str) + 32); - sprintf(oname, "%s.dat", str); + oname = malloc(strlen(dip->dip_name) + strlen(post) + 32); + sprintf(oname, "%s%s_plat.dat", dip->dip_name, post); if ((pp->fp = my_fopen(oname, "w")) == NULL) { perror(oname); return NULL; diff --git a/btt/rstats.c b/btt/rstats.c index c0d2904..71f010b 100644 --- a/btt/rstats.c +++ b/btt/rstats.c @@ -51,11 +51,13 @@ static int do_open(struct files *fip, char *bn, char *pn) return -1; } -static int init_rsip(struct rstat *rsip, char *bn) +static int init_rsip(struct rstat *rsip, struct d_info *dip) { + char *nm = dip ? dip->dip_name : "sys"; + rsip->ios = rsip->nblks = 0; - if (do_open(&rsip->files[0], bn, "iops_fp") || - do_open(&rsip->files[1], bn, "mbps_fp")) + if (do_open(&rsip->files[0], nm, "iops_fp") || + do_open(&rsip->files[1], nm, "mbps_fp")) return -1; list_add_tail(&rsip->head, &rstats); @@ -92,11 +94,11 @@ static void __add(struct rstat *rsip, double cur, unsigned long long nblks) rsip->nblks += nblks; } -void *rstat_alloc(char *bn) +void *rstat_alloc(struct d_info *dip) { struct rstat *rsip = malloc(sizeof(*rsip)); - if (!init_rsip(rsip, bn)) + if (!init_rsip(rsip, dip)) return rsip; free(rsip); @@ -121,7 +123,7 @@ void rstat_add(void *ptr, double cur, unsigned long long nblks) int rstat_init(void) { - sys_info = rstat_alloc("sys"); + sys_info = rstat_alloc(NULL); return sys_info != NULL; } @@ -205,10 +205,12 @@ long long seek_dist(struct seeki *sip, struct io *iop) return dist; } -void *seeki_alloc(char *str) +void *seeki_alloc(struct d_info *dip, char *post) { + char str[256]; struct seeki *sip = malloc(sizeof(struct seeki)); + sprintf(str, "%s%s", dip->dip_name, post); sip->rfp = seek_open(str, 'r'); sip->wfp = seek_open(str, 'w'); sip->cfp = seek_open(str, 'c'); @@ -222,8 +224,8 @@ void *seeki_alloc(char *str) memset(&sip->sps, 0, sizeof(sip->sps)); - oname = malloc(strlen(sps_name) + strlen(str) + 32); - sprintf(oname, "%s_%s.dat", sps_name, str); + oname = malloc(strlen(sps_name) + strlen(dip->dip_name) + 32); + sprintf(oname, "%s_%s.dat", sps_name, dip->dip_name); if ((sip->sps_fp = my_fopen(oname, "w")) == NULL) perror(oname); else diff --git a/btt/unplug_hist.c b/btt/unplug_hist.c index 8fd4285..89995de 100644 --- a/btt/unplug_hist.c +++ b/btt/unplug_hist.c @@ -26,18 +26,18 @@ #define NBKTS (EXCESS_BKT + 1) struct hist_bkt { - __u32 dev; + struct d_info *dip; int hist[NBKTS * sizeof(int)]; }; -void *unplug_hist_alloc(__u32 device) +void *unplug_hist_alloc(struct d_info *dip) { struct hist_bkt *hbp; if (unplug_hist_name == NULL) return NULL; hbp = malloc(sizeof(*hbp)); - hbp->dev = device; + hbp->dip = dip; memset(hbp->hist, 0, NBKTS * sizeof(int)); return hbp; @@ -66,11 +66,12 @@ void unplug_hist_free(void *arg) if (arg) { FILE *fp; struct hist_bkt *hbp = arg; - int mjr = hbp->dev >> MINORBITS; - int mnr = hbp->dev & ((1 << MINORBITS) - 1); - char *oname = malloc(strlen(unplug_hist_name) + 32); + size_t tlen = strlen(unplug_hist_name) + + strlen(hbp->dip->dip_name) + 32; + char *oname = malloc(tlen); - sprintf(oname, "%s_%03d,%03d.dat", unplug_hist_name, mjr, mnr); + sprintf(oname, "%s_%s.dat", unplug_hist_name, + hbp->dip->dip_name); if ((fp = my_fopen(oname, "w")) != NULL) { int i; |