Skip to content

Commit f1cac6a

Browse files
author
Peter Zijlstra
committed
x86/perf: Make sure to program the counter value for stopped events on migration
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: a4eaf7f ("perf: Rework the PMU methods") Reported-by: Dapeng Mi <[email protected]> Reported-by: Ian Rogers <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Dapeng Mi <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 8d5fae6 commit f1cac6a

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

arch/x86/events/core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1374,8 +1374,10 @@ static void x86_pmu_enable(struct pmu *pmu)
13741374

13751375
cpuc->events[hwc->idx] = event;
13761376

1377-
if (hwc->state & PERF_HES_ARCH)
1377+
if (hwc->state & PERF_HES_ARCH) {
1378+
static_call(x86_pmu_set_period)(event);
13781379
continue;
1380+
}
13791381

13801382
/*
13811383
* if cpuc->enabled = 0, then no wrmsr as

0 commit comments

Comments
 (0)