Skip to content

perf/x86/amd/uncore: Drop redundant counter slot searches

Usama Arif linux-perf-users lkml 1 version Applied

Status from this message: The following commit has been merged into the perf/core branch of tip:

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 1 replyApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/2perf/x86/amd/uncore: Remove redundant event slot scanarch/x86/events/amd/uncore.c+6 -80 replies
2/2perf/x86/amd/uncore: Free counter slot by indexarch/x86/events/amd/uncore.c+3 -70 replies

Reviews trailers per patch

None of the 2 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchSandipan Das
SeriesR-b
1/2
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/2] perf/x86/amd/uncore: Drop redundant counter slot searches

Both amd_uncore_add() and amd_uncore_del() search ctx->events[] for an event whose counter slot is already recorded in event->hw.idx.

Perf serializes ->add() and ->del() for an event, and the driver never moves an installed event between slots, so an installed event can only be at the recorded index. Both searches are redundant.

Neither callback is normally hot. That changes once more events target a PMU than it has counters. Perf then multiplexes them: every mux tick deschedules the resident set and schedules the next one, so both callbacks run for each rotated event on every tick.

Meta's fleet-wide profiles attribute 1.1% of kernel CPU time, excluding do_idle(), to amd_uncore_add() and amd_uncore_del() combined. On the host that exposed this, a workload holding 15,782 perf event file descriptors drove 56,575 calls per second into each callback from mux rotation, against a 16-counter DF PMU.

Patch 1 removes the scan in amd_uncore_add(). It walks every counter before the free slot search, which is the common case once multiplexing has scheduled the event out.

Patch 2 makes amd_uncore_del() free the recorded slot directly instead of rescanning from slot zero. Deleting all events from a full PMU with N counters drops from N * (N + 1) / 2 compare-exchanges to N.

No functional change intended.

Usama Arif (2):
perf/x86/amd/uncore: Remove redundant event slot scan perf/x86/amd/uncore: Free counter slot by index

 arch/x86/events/amd/uncore.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)
Signature · 1 line
2.53.0-Meta