Skip to content

Commit f1f9651

Browse files
Dapeng MiPeter Zijlstra
authored andcommitted
perf: Fix 0 count issue of cpu-clock
Currently cpu-clock event always returns 0 count, e.g., perf stat -e cpu-clock -- sleep 1 Performance counter stats for 'sleep 1': 0 cpu-clock # 0.000 CPUs utilized 1.002308394 seconds time elapsed The root cause is the commit 'bc4394e5e79c ("perf: Fix the throttle error of some clock events")' adds PERF_EF_UPDATE flag check before calling cpu_clock_event_update() to update the count, however the PERF_EF_UPDATE flag is never set when the cpu-clock event is stopped in counting mode (pmu->dev() -> cpu_clock_event_del() -> cpu_clock_event_stop()). This leads to the cpu-clock event count is never updated. To fix this issue, force to set PERF_EF_UPDATE flag for cpu-clock event just like what task-clock does. Fixes: bc4394e ("perf: Fix the throttle error of some clock events") Signed-off-by: Dapeng Mi <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Ian Rogers <[email protected]> Acked-by: Namhyung Kim <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent a24074c commit f1f9651

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/events/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11901,7 +11901,7 @@ static int cpu_clock_event_add(struct perf_event *event, int flags)
1190111901

1190211902
static void cpu_clock_event_del(struct perf_event *event, int flags)
1190311903
{
11904-
cpu_clock_event_stop(event, flags);
11904+
cpu_clock_event_stop(event, PERF_EF_UPDATE);
1190511905
}
1190611906

1190711907
static void cpu_clock_event_read(struct perf_event *event)

0 commit comments

Comments
 (0)