]> sourceware.org Git - systemtap.git/commitdiff
2005-11-21 Frank Ch. Eigler <fche@elastic.org>
authorfche <fche>
Mon, 21 Nov 2005 19:02:44 +0000 (19:02 +0000)
committerfche <fche>
Mon, 21 Nov 2005 19:02:44 +0000 (19:02 +0000)
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.

ChangeLog
stapprobes.5.in
tapsets.cxx
testsuite/buildok/fourteen.stp

index d54cc0a2c6b18a1cb9d3ba8759f8a240e2e99ede..ffb2c04cd54a5d9583b6889d72ebceb497f290b8 100644 (file)
--- 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
index 7a3a3edd58a1e53dcd1b0aa3f85cd7d7b461a250..2db9cf1f1a16d344184169459ad6d110fee84cbb 100644 (file)
@@ -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
 
index 99c4c38ac7f7457748521a3ab6580d14eba23395..5e6497f4ae86f1a7e0c2ec136188bbe8f5fdde5f 100644 (file)
@@ -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);
index dd231696479009a83376887bba92df85de669833..4490052fb47bd53cfcbe696272b7addf9a0279fa 100755 (executable)
@@ -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)) }
This page took 0.046565 seconds and 5 git commands to generate.