+2006-11-01 Josh Stone <joshua.i.stone@intel.com>
+
+ * tapsets.cxx (timer_derived_probe_group::emit_interval): New -
+ Fixes randomization for jiffies timers in ms mode.
+ (timer_derived_probe_group::emit_module_decls): Use emit_interval.
+ (timer_derived_probe_group::emit_module_init): Ditto.
+
+
2006-11-01 <dsmith@redhat.com>
* translate.cxx (delete_statement_operand_visitor::visit_symbol):
struct timer_derived_probe_group: public generic_dpg<timer_derived_probe>
{
+ void emit_interval (translator_output* o);
public:
void emit_module_decls (systemtap_session& s);
void emit_module_init (systemtap_session& s);
}
+void
+timer_derived_probe_group::emit_interval (translator_output* o)
+{
+ o->line() << "({";
+ o->newline(1) << "unsigned i = stp->intrv;";
+ o->newline() << "if (stp->rnd != 0)";
+ o->newline(1) << "i += _stp_random_pm(stp->rnd);";
+ o->newline(-1) << "stp->ms ? msecs_to_jiffies(i) : i;";
+ o->newline(-1) << "})";
+}
+
+
void
timer_derived_probe_group::emit_module_decls (systemtap_session& s)
{
s.op->newline(1) << "struct stap_timer_probe* stp = & stap_timer_probes [val];";
common_probe_entryfn_prologue (s.op, "STAP_SESSION_RUNNING");
s.op->newline() << "c->probe_point = stp->pp;";
- s.op->newline() << "mod_timer (& stp->timer_list,";
- s.op->newline(1) << "jiffies ";
- s.op->newline() << "+ (stp->ms ? msecs_to_jiffies(stp->intrv) : stp->intrv)";
- s.op->newline() << "+ _stp_random_pm (stp->rnd));";
- s.op->indent(-1);
+ s.op->newline() << "mod_timer (& stp->timer_list, jiffies + ";
+ emit_interval (s.op);
+ s.op->line() << ");";
s.op->newline() << "(*stp->ph) (c);";
common_probe_entryfn_epilogue (s.op);
s.op->newline(-1) << "}";
s.op->newline() << "stp->timer_list.function = & enter_timer_probe;";
s.op->newline() << "stp->timer_list.data = i;"; // NB: important!
// copy timer renew calculations from above :-(
- s.op->newline() << "stp->timer_list.expires = jiffies";
- s.op->newline(1) << "+ (stp->ms ? msecs_to_jiffies(stp->intrv) : stp->intrv)";
- s.op->newline() << "+ _stp_random_pm (stp->rnd);";
- s.op->newline(-1) << "add_timer (& stp->timer_list);";
+ s.op->newline() << "stp->timer_list.expires = jiffies + ";
+ emit_interval (s.op);
+ s.op->line() << ";";
+ s.op->newline() << "add_timer (& stp->timer_list);";
// note: no partial failure rollback is needed: add_timer cannot fail.
s.op->newline(-1) << "}"; // for loop
}