Skip to content

[linux-nvidia-6.17] Backport perf: Fix 0 count issue of cpu-clock#309

Open
nvmochs wants to merge 1 commit intoNVIDIA:24.04_linux-nvidia-6.17-nextfrom
nvmochs:617_hwe_pmu_fix
Open

[linux-nvidia-6.17] Backport perf: Fix 0 count issue of cpu-clock#309
nvmochs wants to merge 1 commit intoNVIDIA:24.04_linux-nvidia-6.17-nextfrom
nvmochs:617_hwe_pmu_fix

Conversation

@nvmochs
Copy link
Collaborator

@nvmochs nvmochs commented Feb 3, 2026

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")

Reviewed-by: Ian Rogers [email protected]
Acked-by: Namhyung Kim [email protected]
Link: https://patch.msgid.link/[email protected] (cherry picked from commit f1f9651)


LP: https://bugs.launchpad.net/ubuntu/+source/linux-nvidia/+bug/2139648

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]
(cherry picked from commit f1f9651)
Signed-off-by: Matthew R. Ochs <[email protected]>
@nvmochs nvmochs changed the title perf: Fix 0 count issue of cpu-clock [linux-nvidia-6.17] Backport perf: Fix 0 count issue of cpu-clock Feb 3, 2026
@jamieNguyenNVIDIA
Copy link
Collaborator

Acked-by: Jamie Nguyen <[email protected]>

Copy link
Collaborator

@clsotog clsotog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acked-by: Carol L Soto <[email protected]>

@nirmoy
Copy link
Collaborator

nirmoy commented Feb 3, 2026

Acked-by: Nirmoy Das <[email protected]>

@nvmochs
Copy link
Collaborator Author

nvmochs commented Feb 3, 2026

Sent to Canonical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants