Re: [PATCH v4 1/2] perf tool_pmu: Make tool PMU events respect enable/disable
From: Namhyung Kim
Date: Tue May 19 2026 - 02:49:44 EST
On Mon, May 18, 2026 at 06:41:05PM -0700, Ian Rogers wrote:
> Tool PMU events (duration_time, user_time, system_time) currently
> count from when the event is opened to when it is read. This causes
> issues with features like the delay option (-D) or control fd, where
> events are opened but should not start counting immediately.
>
> Make these events behave more like regular counters by implementing
> proper enable and disable support. Add accumulated_time to struct
> evsel to track time while enabled, and implement enable/disable CPU
> callbacks to start/stop counting.
>
> Also generalize userspace PMU mixed group handling. Userspace synthetic
> PMUs (type > PERF_PMU_TYPE_PE_END) do not have kernel implementations and
> cannot be grouped in the kernel (opened with group_fd = -1), and are
> skipped by kernel enable/disable calls. Iterate over group members in
> userspace and manually enable/disable any members if the leader or the
> member is a non-perf-event open PMU, and synchronize their disabled flags.
Can we divide the commit into smaller pieces? I think we can have
* preparation for accumulated_time
* implement enable/disable for tool PMU
* wire them to evsel__{enable,disable}[_cpu]
* support group members properly
What do you think?
Thanks,
Namhyung
>
> Fixes: b71f46a6a708 ("perf stat: Remove hard coded shadow metrics")
> Reported-by: Francesco Nigro <nigro.fra@xxxxxxxxx>
> Closes: https://lore.kernel.org/linux-perf-users/20260517093650.2540920-1-nigro.fra@xxxxxxxxx/
> Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> Assisted-by: Antigravity:gemini-3-flash
> ---
> tools/perf/util/evlist.c | 10 +-
> tools/perf/util/evsel.c | 197 ++++++++++++++++++++++-------
> tools/perf/util/evsel.h | 15 ++-
> tools/perf/util/tool_pmu.c | 250 +++++++++++++++++++++++++++++--------
> tools/perf/util/tool_pmu.h | 4 +
> 5 files changed, 377 insertions(+), 99 deletions(-)