Cleaned up devs that have no data
authorAlan D. Brunelle <alan.brunelle@hp.com>
Thu, 12 Feb 2009 13:01:42 +0000 (08:01 -0500)
committerAlan D. Brunelle <alan.brunelle@hp.com>
Thu, 12 Feb 2009 13:01:42 +0000 (08:01 -0500)
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 <alan.brunelle@hp.com>
btt/bt_timeline.c
btt/devs.c
btt/globals.h

index dda46222a1163be6df88879a9ac0f992d2411630..9c6ab94835c7cec7843145b5a7e5b01b8610fdf9 100644 (file)
@@ -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);
 
index ea560a2c9506dfb339509060500c333037e8ff02..9480d61276bbe4dd5cabc29bca930460c5d65599 100644 (file)
@@ -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);
+       }
+}
index 9b73a98e4c96bf13450a56d95c48f2bfd04756a6..36c30c32e53aed25cda30c4a5786bc537803da91 100644 (file)
@@ -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);