summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--stapprobes.5.in11
-rw-r--r--tapsets.cxx35
-rwxr-xr-xtestsuite/buildok/fourteen.stp2
4 files changed, 48 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index d54cc0a2..ffb2c04c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2005-11-21 Frank Ch. Eigler <fche@elastic.org>
+
+ PR 1276
+ From Josh Stone <joshua.i.stone@intel.com>:
+ * tapsets.cxx (timer_derived_probe, timer_builder,
+ register_standard_tapsets): Support timer.ms() variety.
+ * stapprobes.5.in: Document it.
+ * testsuite/builok/fourteen.stp: Test its buildability.
+
2005-11-18 Martin Hunt <hunt@redhat.com>
PR 1837
diff --git a/stapprobes.5.in b/stapprobes.5.in
index 7a3a3edd..2db9cf1f 100644
--- a/stapprobes.5.in
+++ b/stapprobes.5.in
@@ -69,6 +69,17 @@ reasonable range (1 to around a million), and M is restricted to be
smaller than N. There are no target variables provided in either
context. It is possible for such probes to be run concurrently on
a multi-processor computer.
+.PP
+Alternatively, intervals may be specified in units of milliseconds.
+There are two probe point variants similar to the jiffies timer:
+.SAMPLE
+timer.ms(N)
+timer.ms(N).randomize(M)
+.ESAMPLE
+Here, N and M are specified in milliseconds. The probe intervals will be
+rounded up to the nearest jiffies interval for the actual timer. If the
+"randomize" component is given, then the random value will be added to the
+interval before the conversion to jiffies.
.SS DWARF
diff --git a/tapsets.cxx b/tapsets.cxx
index 99c4c38a..5e6497f4 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -2935,8 +2935,9 @@ dwarf_builder::build(systemtap_session & sess,
struct timer_derived_probe: public derived_probe
{
int64_t interval, randomize;
+ bool time_is_msecs;
- timer_derived_probe (probe* p, probe_point* l, int64_t i, int64_t r);
+ timer_derived_probe (probe* p, probe_point* l, int64_t i, int64_t r, bool ms=false);
virtual void emit_registrations (translator_output * o, unsigned i);
virtual void emit_deregistrations (translator_output * o, unsigned i);
@@ -2944,8 +2945,8 @@ struct timer_derived_probe: public derived_probe
};
-timer_derived_probe::timer_derived_probe (probe* p, probe_point* l, int64_t i, int64_t r):
- derived_probe (p, l), interval (i), randomize (r)
+timer_derived_probe::timer_derived_probe (probe* p, probe_point* l, int64_t i, int64_t r, bool ms):
+ derived_probe (p, l), interval (i), randomize (r), time_is_msecs(ms)
{
if (interval <= 0 || interval > 1000000) // make i and r fit into plain ints
throw semantic_error ("invalid interval for jiffies timer");
@@ -2963,7 +2964,15 @@ void
timer_derived_probe::emit_registrations (translator_output* o, unsigned j)
{
o->newline() << "init_timer (& timer_" << j << ");";
- o->newline() << "timer_" << j << ".expires = jiffies + " << interval << ";";
+ o->newline() << "timer_" << j << ".expires = jiffies + ";
+ if (time_is_msecs)
+ o->line() << "msecs_to_jiffies(";
+ o->line() << interval;
+ if (randomize)
+ o->line() << " + _stp_random_pm(" << randomize << ")";
+ if (time_is_msecs)
+ o->line() << ")";
+ o->line() << ";";
o->newline() << "timer_" << j << ".function = & enter_" << j << ";";
o->newline() << "add_timer (& timer_" << j << ");";
}
@@ -3002,10 +3011,14 @@ timer_derived_probe::emit_probe_entries (translator_output* o, unsigned j)
o->newline(-1) << "}";
o->newline();
- o->newline() << "mod_timer (& timer_" << j << ", "
- << "jiffies + " << interval;
+ o->newline() << "mod_timer (& timer_" << j << ", jiffies + ";
+ if (time_is_msecs)
+ o->line() << "msecs_to_jiffies(";
+ o->line() << interval;
if (randomize)
o->line() << " + _stp_random_pm(" << randomize << ")";
+ if (time_is_msecs)
+ o->line() << ")";
o->line() << ");";
o->newline() << "c->probe_point = probe_point;";
@@ -3035,7 +3048,8 @@ timer_derived_probe::emit_probe_entries (translator_output* o, unsigned j)
struct timer_builder: public derived_probe_builder
{
- timer_builder() {}
+ bool time_is_msecs;
+ timer_builder(bool ms=false): time_is_msecs(ms) {}
virtual void build(systemtap_session & sess,
probe * base,
probe_point * location,
@@ -3045,11 +3059,12 @@ struct timer_builder: public derived_probe_builder
int64_t jn, rn;
bool jn_p, rn_p;
- jn_p = get_param (parameters, "jiffies", jn);
+ jn_p = get_param (parameters, time_is_msecs ? "ms" : "jiffies", jn);
rn_p = get_param (parameters, "randomize", rn);
finished_results.push_back(new timer_derived_probe(base, location,
- jn, rn_p ? rn : 0));
+ jn, rn_p ? rn : 0,
+ time_is_msecs));
}
};
@@ -3067,6 +3082,8 @@ register_standard_tapsets(systemtap_session & s)
s.pattern_root->bind("end")->bind(new be_builder(false));
s.pattern_root->bind("timer")->bind_num("jiffies")->bind(new timer_builder());
s.pattern_root->bind("timer")->bind_num("jiffies")->bind_num("randomize")->bind(new timer_builder());
+ s.pattern_root->bind("timer")->bind_num("ms")->bind(new timer_builder(true));
+ s.pattern_root->bind("timer")->bind_num("ms")->bind_num("randomize")->bind(new timer_builder(true));
// kernel/module parts
dwarf_derived_probe::register_patterns(s.pattern_root);
diff --git a/testsuite/buildok/fourteen.stp b/testsuite/buildok/fourteen.stp
index dd231696..4490052f 100755
--- a/testsuite/buildok/fourteen.stp
+++ b/testsuite/buildok/fourteen.stp
@@ -3,4 +3,6 @@
global i, j
probe timer.jiffies(100) { i++ }
probe timer.jiffies(100).randomize(100) { j++ }
+probe timer.ms(100) { i++ }
+probe timer.ms(100).randomize(100) { j++ }
probe end { log ("i=" . string(i) . " j=" . string(j)) }