From a85559e84788157b3d8d4bdb2f36209e443131c3 Mon Sep 17 00:00:00 2001 From: "Yichun Zhang (agentzh)" Date: Tue, 18 Jun 2024 16:11:15 -0700 Subject: [PATCH] PR31907: STP_TIMING: BUG: using smp_processor_id() in preemptible on debug kernels Thanks Junlong Li for the patch. --- tapsets.cxx | 6 +++++- translate.cxx | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tapsets.cxx b/tapsets.cxx index 5a82b9a71..9bb8de3be 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -311,7 +311,11 @@ common_probe_entryfn_epilogue (systemtap_session& s, s.op->newline() << "#ifdef STP_TIMING"; // STP_TIMING requires min, max, avg (and thus count and sum), but not variance. - s.op->newline() << "if (likely (stat)) _stp_stat_add(stat, cycles_elapsed, 1, 1, 1, 1, 0);"; + s.op->newline() << "if (likely (stat)) {"; + s.op->newline(1) << "preempt_disable();"; + s.op->newline() << "_stp_stat_add(stat, cycles_elapsed, 1, 1, 1, 1, 0);"; + s.op->newline() << "preempt_enable_no_resched();"; + s.op->newline(-1) << "}"; s.op->newline() << "#endif"; if (overload_processing && !s.runtime_usermode_p()) diff --git a/translate.cxx b/translate.cxx index 8fb320e66..04b13d9d3 100644 --- a/translate.cxx +++ b/translate.cxx @@ -3786,10 +3786,12 @@ c_unparser_assignment::c_assignop(tmpvar & res, assert(rval.type() == pe_long); assert(res.type() == pe_long); + o->newline() << "preempt_disable();"; o->newline() << "_stp_stat_add (" << lval << ", " << rval << ", " << stat_op_count << ", " << stat_op_sum << ", " << stat_op_min << ", " << stat_op_max << ", " << stat_op_variance << ");"; + o->newline() << "preempt_enable_no_resched();"; res = rval; } else if (res.type() == pe_long) -- 2.43.5