aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan D. Brunelle <alan.brunelle@hp.com>2009-04-06 07:30:16 -0400
committerAlan D. Brunelle <alan.brunelle@hp.com>2009-04-06 07:30:16 -0400
commitbb4a66074cecd59afc37f0053fdf42661503f51c (patch)
treee629b9980de5311cc8daa067801b15321a101d0b
parent15d67efcf8859d0f64d2ba38249bc50f87c30b57 (diff)
downloadblktrace-bb4a66074cecd59afc37f0053fdf42661503f51c.tar.gz
Fixed plug/unplug logic in btt
Was not accounting for unplugged time due to timeout unplugs.
-rw-r--r--btt/devs.c18
-rw-r--r--btt/globals.h2
-rw-r--r--btt/output.c17
3 files changed, 21 insertions, 16 deletions
diff --git a/btt/devs.c b/btt/devs.c
index ff55aa7..3578633 100644
--- a/btt/devs.c
+++ b/btt/devs.c
@@ -234,10 +234,16 @@ void dip_plug(__u32 dev, double cur_time)
{
struct d_info *dip = __dip_find(dev);
- if (!dip || dip->is_plugged) return;
+ if (dip && !dip->is_plugged) {
+ dip->is_plugged = 1;
+ dip->last_plug = cur_time;
+ }
+}
- dip->is_plugged = 1;
- dip->last_plug = cur_time;
+static inline void unplug(struct d_info *dip, double cur_time)
+{
+ dip->is_plugged = 0;
+ dip->plugged_time += (cur_time - dip->last_plug);
}
void dip_unplug(__u32 dev, double cur_time, __u64 nios_up)
@@ -246,9 +252,8 @@ void dip_unplug(__u32 dev, double cur_time, __u64 nios_up)
if (dip && dip->is_plugged) {
dip->nplugs++;
- dip->plugged_time += (cur_time - dip->last_plug);
- dip->is_plugged = 0;
dip->nios_up += nios_up;
+ unplug(dip, cur_time);
}
}
@@ -257,10 +262,9 @@ void dip_unplug_tm(__u32 dev, double cur_time, __u64 nios_up)
struct d_info *dip = __dip_find(dev);
if (dip && dip->is_plugged) {
- dip->plugged_time += (cur_time - dip->last_plug);
- dip->n_timer_unplugs++;
dip->nios_upt += nios_up;
dip->nplugs_t++;
+ unplug(dip, cur_time);
}
}
diff --git a/btt/globals.h b/btt/globals.h
index c6c8c99..d05d996 100644
--- a/btt/globals.h
+++ b/btt/globals.h
@@ -143,7 +143,7 @@ struct d_info {
__u32 device;
int pre_culling;
- int is_plugged, nplugs, nplugs_t, n_timer_unplugs;
+ int is_plugged, nplugs, nplugs_t;
__u64 nios_up, nios_upt;
double start_time, last_plug, plugged_time, end_time;
};
diff --git a/btt/output.c b/btt/output.c
index 4e9b360..8693de7 100644
--- a/btt/output.c
+++ b/btt/output.c
@@ -513,7 +513,7 @@ void output_pip_avg(FILE *ofp, char *hdr, ai_pip_t (*func)(struct p_info *))
int n_plugs;
struct plug_info {
- long n_plugs, n_timer_unplugs;
+ long n_plugs, n_unplugs_t;
double t_percent;
} plug_info;
@@ -523,25 +523,26 @@ void __dip_output_plug(struct d_info *dip, void *arg)
FILE *ofp = arg;
double delta, pct;
- if (dip->nplugs > 0) {
- if (dip->is_plugged) dip_unplug(dip->device, dip->end_time, 0);
+ if (dip->is_plugged)
+ dip_unplug(dip->device, dip->end_time, 0);
+ if ((dip->nplugs + dip->nplugs_t) > 0) {
delta = dip->end_time - dip->start_time;
- pct = 100.0 * ((dip->plugged_time / delta) / delta);
+ pct = 100.0 * (dip->plugged_time / delta);
fprintf(ofp, "%10s | %10d(%10d) | %13.9lf%%\n",
make_dev_hdr(dev_info, 15, dip, 1),
- dip->nplugs, dip->n_timer_unplugs, pct);
+ dip->nplugs, dip->nplugs_t, pct);
if (easy_parse_avgs) {
fprintf(xavgs_ofp,
"PLG %s %d %d %.9lf\n",
make_dev_hdr(dev_info, 15, dip, 0),
- dip->nplugs, dip->n_timer_unplugs, pct);
+ dip->nplugs, dip->nplugs_t, pct);
}
n_plugs++;
plug_info.n_plugs += dip->nplugs;
- plug_info.n_timer_unplugs += dip->n_timer_unplugs;
+ plug_info.n_unplugs_t += dip->nplugs_t;
plug_info.t_percent += pct;
}
}
@@ -552,7 +553,7 @@ void __dip_output_plug_all(FILE *ofp, struct plug_info *p)
fprintf(ofp, "%10s | %10s %10s | %s\n",
"Overall", "# Plugs", "# Timer Us", "% Time Q Plugged");
fprintf(ofp, "%10s | %10ld(%10ld) | %13.9lf%%\n", "Average",
- p->n_plugs / n_plugs, p->n_timer_unplugs / n_plugs,
+ p->n_plugs / n_plugs, p->n_unplugs_t / n_plugs,
p->t_percent / n_plugs);
}