Skip to content

[24.04_linux-nvidia-6.17] Backport perf tool_pmu: Use old_count when computing count values for time events#471

Closed
nvmochs wants to merge 1 commit into
NVIDIA:24.04_linux-nvidia-6.17-nextfrom
nvmochs:perf_duration_time_617
Closed

[24.04_linux-nvidia-6.17] Backport perf tool_pmu: Use old_count when computing count values for time events#471
nvmochs wants to merge 1 commit into
NVIDIA:24.04_linux-nvidia-6.17-nextfrom
nvmochs:perf_duration_time_617

Conversation

@nvmochs

@nvmochs nvmochs commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

This upstream patch from v6.19 resolves an issue (injected with a v6.16 commit) when running the perf command to measure duration time.

When running in interval mode every third count of a time event isn't
showing properly:

$ perf stat -e duration_time -a -I 1000
     1.001082862      1,002,290,425      duration_time
     2.004264262      1,003,183,516      duration_time
     3.007381401      <not counted>      duration_time
     4.011160141      1,003,705,631      duration_time
     5.014515385      1,003,290,110      duration_time
     6.018539680      <not counted>      duration_time
     7.022065321      1,003,591,720      duration_time

Patch: torvalds/linux@bdf96c4
LKML: https://lore.kernel.org/all/20251113180517.44096-4-irogers@google.com/

Backport the patch to linux-nvidia-6.17.

Verified by running the perf command with the fix:

nvidia@GB200:~/mochs/perf_backport_test/NV-Kernels/tools/perf$ ./perf stat -e duration_time -I 1000
./perf stat -e duration_time -I 1000
#           time             counts unit events
     1.001015119         1008476614      duration_time                                                         
     2.004164516         1003143445      duration_time                                                         
     3.008193019         1004027831      duration_time                                                         
     4.012104305         1003915414      duration_time                                                         
     5.016211177         1004100920      duration_time                                                         
     6.019747039         1003552054      duration_time                                                         
     6.674403830          654646104      duration_time

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

When running in interval mode every third count of a time event isn't
showing properly:
```
$ perf stat -e duration_time -a -I 1000
     1.001082862      1,002,290,425      duration_time
     2.004264262      1,003,183,516      duration_time
     3.007381401      <not counted>      duration_time
     4.011160141      1,003,705,631      duration_time
     5.014515385      1,003,290,110      duration_time
     6.018539680      <not counted>      duration_time
     7.022065321      1,003,591,720      duration_time
```
The regression came in with a different fix, found through bisection,
commit 68cb156 ("perf tool_pmu: Fix aggregation on
duration_time"). The issue is caused by the enabled and running time
of the event matching the old_count's and creating a delta of 0, which
is indicative of an error.

Fixes: 68cb156 ("perf tool_pmu: Fix aggregation on duration_time")
Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
(backported from commit bdf96c4)
[mochs: Minor context adjustment due to absent definitions]
Signed-off-by: Matthew R. Ochs <mochs@nvidia.com>
@nvmochs nvmochs requested review from clsotog and nirmoy June 24, 2026 00:05
@nirmoy nirmoy added the help wanted Extra attention is needed label Jun 24, 2026
@nirmoy

nirmoy commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

BaseOS Kernel Review

Summary

Only a low-severity issue found: in tools/perf/util/tool_pmu.c, the time conversion uses a floating-point literal (1e9), which can lose precision for very large __u64 deltas, though practical impact on perf time stats is negligible.

Findings: Critical: 0, High: 0, Medium: 0, Low: 1

Latest watcher review: open review

Kernel deb build: failed (failure log, build artifacts)

Head: b30d2bbf616f

This comment is maintained by nv-pr-bot. It is updated when the GitHub watcher publishes a newer review.

@github-actions

Copy link
Copy Markdown
Contributor

PR Validation Report

Patchscan ✅ No Missing Fixes

All cherry-picked commits checked — no missing upstream fixes found.

PR Lint ❌ Errors found

Details
Checking 1 commits...

Cherry-pick digest:
E: b30d2bbf616f ("perf tool_pmu: Use old_count when comput"): patch-ID mismatch with upstream bdf96c4ecd69
┌──────────────┬──────────────────────────────────────────────────────────────────┬────────────┬─────────┬───────────────────────────┐
│ Local        │ Referenced upstream / Patch subject                              │ Patch-ID   │ Subject │ SoB chain                 │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ b30d2bbf616f │ bdf96c4ecd69 perf tool_pmu: Use old_count when computing count v │ MISMATCH   │ match   │ preserved + mochs added   │
└──────────────┴──────────────────────────────────────────────────────────────────┴────────────┴─────────┴───────────────────────────┘

Lint: all checks passed.

@clsotog clsotog left a comment

Copy link
Copy Markdown
Collaborator

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 <csoto@nvidia.com>

@nirmoy nirmoy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Acked-by: Nirmoy Das <nirmoyd@nvidia.com>

@nirmoy nirmoy added has_2_acks and removed help wanted Extra attention is needed has_1_ack labels Jun 24, 2026
@nvmochs

nvmochs commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator Author

Merged, closing PR.

059faeb40d80 (nnoble/nvidia-6.17-next) perf tool_pmu: Use old_count when computing count values for time events

@nvmochs nvmochs closed this Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants