summaryrefslogtreecommitdiffstats
path: root/tapsets.cxx
diff options
context:
space:
mode:
authorwcohen <wcohen>2006-05-02 19:26:34 +0000
committerwcohen <wcohen>2006-05-02 19:26:34 +0000
commit4b17d6af571193c8a78c470ef941bbfea73de253 (patch)
tree9ac3ac53f04b20469b7765c532336f431bac067a /tapsets.cxx
parent86cae39ac23bb8fd44416520b53b8fc74ae9a857 (diff)
downloadsystemtap-steved-4b17d6af571193c8a78c470ef941bbfea73de253.tar.gz
systemtap-steved-4b17d6af571193c8a78c470ef941bbfea73de253.tar.xz
systemtap-steved-4b17d6af571193c8a78c470ef941bbfea73de253.zip
"-t" option to collect information the number of times a probe runs and
the average amount of time spent in the probe.
Diffstat (limited to 'tapsets.cxx')
-rw-r--r--tapsets.cxx26
1 files changed, 25 insertions, 1 deletions
diff --git a/tapsets.cxx b/tapsets.cxx
index 50386480..278cc60c 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -94,7 +94,13 @@ derived_probe::emit_probe_prologue (translator_output* o,
{
o->newline() << "struct context* c;";
o->newline() << "unsigned long flags;";
+ o->newline() << "#ifdef STP_TIMING";
+ o->newline() << "cycles_t cycles_atstart;";
+ o->newline() << "#endif";
o->newline() << "local_irq_save (flags);";
+ o->newline() << "#ifdef STP_TIMING";
+ o->newline() << "cycles_atstart = get_cycles ();";
+ o->newline() << "#endif";
o->newline() << "c = per_cpu_ptr (contexts, smp_processor_id());";
o->newline() << "if (atomic_read (&session_state) != " << statereq << ")";
o->newline(1) << "goto probe_epilogue;";
@@ -139,7 +145,17 @@ derived_probe::emit_probe_epilogue (translator_output* o)
o->newline() << "atomic_dec (&c->busy);";
o->newline(-1) << "probe_epilogue:";
- o->newline(1) << "local_irq_restore (flags);";
+ o->newline(1) << "#ifdef STP_TIMING";
+ o->newline() << "{";
+ o->newline(1) << "cycles_t cycles_atend = get_cycles ();";
+ o->newline() << "int64_t cycles_elapsed = (cycles_atend > cycles_atstart)";
+ o->newline(1) << "? (int64_t) (cycles_atend - cycles_atstart)";
+ o->newline() << ": (int64_t) (~(cycles_t)0) - cycles_atstart + cycles_atend + 1;";
+ o->newline() << "_stp_stat_add(time_" << name << ",cycles_elapsed);";
+ o->indent(-1);
+ o->newline(-1) << "}";
+ o->newline() << "#endif";
+ o->newline() << "local_irq_restore (flags);";
}
@@ -198,6 +214,10 @@ be_derived_probe::emit_deregistrations (translator_output* o)
void
be_derived_probe::emit_probe_entries (translator_output* o)
{
+ o->newline() << "#ifdef STP_TIMING";
+ o->newline() << "static __cacheline_aligned Stat " << "time_" << name << ";";
+ o->newline() << "#endif";
+
for (unsigned i=0; i<locations.size(); i++)
{
probe_point *l = locations[i];
@@ -3056,6 +3076,10 @@ dwarf_derived_probe::emit_probe_entries (translator_output* o)
}
o->newline(-1) << "};";
+ o->newline();
+ o->newline() << "#ifdef STP_TIMING";
+ o->newline() << "static __cacheline_aligned Stat " << "time_" << name << ";";
+ o->newline() << "#endif";
// Construct a single entry function, and a struct kprobe pointing into
// the entry function. The entry function will call the probe function.