From: Alan D. Brunelle Date: Thu, 12 Feb 2009 13:01:42 +0000 (-0500) Subject: Cleaned up devs that have no data X-Git-Tag: blktrace-1.0.1~25 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=52481561c1f0cdc6fa76a15d800b2b228fda7877;p=blktrace.git Cleaned up devs that have no data Working around an issue with older kernels (pre-2.6.19): remaps did not include device-from, so the pad field is being used for a device which never has any Q or Ds done to it (it's an invalid ID). This code removes all such devices before output processing. Signed-off-by: Alan D. Brunelle --- diff --git a/btt/bt_timeline.c b/btt/bt_timeline.c index dda4622..9c6ab94 100644 --- a/btt/bt_timeline.c +++ b/btt/bt_timeline.c @@ -117,6 +117,8 @@ int process(void) io_release(iop); gettimeofday(&tve, NULL); + dip_cleanup(); + if (verbose) { double tps, dt_input = tv2dbl(&tve) - tv2dbl(&tvs); diff --git a/btt/devs.c b/btt/devs.c index ea560a2..9480d61 100644 --- a/btt/devs.c +++ b/btt/devs.c @@ -73,29 +73,33 @@ struct d_info *__dip_find(__u32 device) return NULL; } +void __dip_exit(struct d_info *dip) +{ + list_del(&dip->all_head); + __destroy_heads(dip->heads); + region_exit(&dip->regions); + seeki_exit(dip->seek_handle); + seeki_exit(dip->q2q_handle); + aqd_exit(dip->aqd_handle); + plat_exit(dip->q2d_plat_handle); + plat_exit(dip->q2c_plat_handle); + plat_exit(dip->d2c_plat_handle); + bno_dump_exit(dip->bno_dump_handle); + unplug_hist_exit(dip->unplug_hist_handle); + if (output_all_data) + q2d_release(dip->q2d_priv); + if (dip->pit_fp) + fclose(dip->pit_fp); + free(dip); +} + void dip_exit(void) { - struct d_info *dip; struct list_head *p, *q; list_for_each_safe(p, q, &all_devs) { - dip = list_entry(p, struct d_info, all_head); - - __destroy_heads(dip->heads); - region_exit(&dip->regions); - seeki_exit(dip->seek_handle); - seeki_exit(dip->q2q_handle); - aqd_exit(dip->aqd_handle); - plat_exit(dip->q2d_plat_handle); - plat_exit(dip->q2c_plat_handle); - plat_exit(dip->d2c_plat_handle); - bno_dump_exit(dip->bno_dump_handle); - unplug_hist_exit(dip->unplug_hist_handle); - if (output_all_data) - q2d_release(dip->q2d_priv); - if (dip->pit_fp) - fclose(dip->pit_fp); - free(dip); + struct d_info *dip = list_entry(p, struct d_info, all_head); + __dip_exit(dip); } } @@ -260,3 +264,15 @@ void dip_unplug_tm(__u32 dev, __u64 nios_up) dip->nplugs_t++; } } + +void dip_cleanup(void) +{ + struct list_head *p, *q; + + list_for_each_safe(p, q, &all_devs) { + struct d_info *dip = list_entry(p, struct d_info, all_head); + + if (dip->n_qs == 0 && dip->n_ds == 0) + __dip_exit(dip); + } +} diff --git a/btt/globals.h b/btt/globals.h index 9b73a98..36c30c3 100644 --- a/btt/globals.h +++ b/btt/globals.h @@ -230,6 +230,7 @@ void dip_plug(__u32 dev, double cur_time); void dip_unplug(__u32 dev, double cur_time, __u64 nio_ups); void dip_unplug_tm(__u32 dev, __u64 nio_ups); void dip_exit(void); +void dip_cleanup(void); /* dip_rb.c */ int rb_insert(struct rb_root *root, struct io *iop);