summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2026-03-11 21:29:14 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-04-02 13:25:13 +0200
commit8f5070236c87b5a99e9f34e22af82740437a331d (patch)
tree694847727c3905bcaec62e1a7adeb842e491a09e /arch
parentde641ea08f8fff6906e169d2576c2ac54e562fbb (diff)
x86/perf: Make sure to program the counter value for stopped events on migration
[ Upstream commit f1cac6ac62d28a9a57b17f51ac5795bf250c12d3 ] Both Mi Dapeng and Ian Rogers noted that not everything that sets HES_STOPPED is required to EF_UPDATE. Specifically the 'step 1' loop of rescheduling explicitly does EF_UPDATE to ensure the counter value is read. However, then 'step 2' simply leaves the new counter uninitialized when HES_STOPPED, even though, as noted above, the thing that stopped them might not be aware it needs to EF_RELOAD -- since it didn't EF_UPDATE on stop. One such location that is affected is throttling, throttle does pmu->stop(, 0); and unthrottle does pmu->start(, 0); possibly restarting an uninitialized counter. Fixes: a4eaf7f14675 ("perf: Rework the PMU methods") Reported-by: Dapeng Mi <dapeng1.mi@linux.intel.com> Reported-by: Ian Rogers <irogers@google.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com> Link: https://patch.msgid.link/20260311204035.GX606826@noisy.programming.kicks-ass.net Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/events/core.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index 818de24921a4..7a6b15b0f1c6 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -1371,8 +1371,10 @@ static void x86_pmu_enable(struct pmu *pmu)
cpuc->events[hwc->idx] = event;
- if (hwc->state & PERF_HES_ARCH)
+ if (hwc->state & PERF_HES_ARCH) {
+ static_call(x86_pmu_set_period)(event);
continue;
+ }
/*
* if cpuc->enabled = 0, then no wrmsr as