From: Namhyung Kim <namhyung@kernel.org>
To: TAKANO Mitsuhiro <takano32@gmail.com>
Cc: Ian Rogers <irogers@google.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
Howard Chu <howardchu95@gmail.com>,
Thomas Falcon <thomas.falcon@intel.com>,
Song Liu <songliubraving@fb.com>,
Hang Zhengyang <hang.zhengyang1010@gmail.com>
Subject: Re: [PATCH v1 06/13] perf pmu: Don't treat tool PMU as a kernel software PMU for event grouping
Date: Mon, 23 Nov 2026 16:16:54 -0800 [thread overview]
Message-ID: <awTXdgY38s2bijW5@google.com> (raw)
In-Reply-To: <179547553247.235629.15166017818384644106@gmail.com>
Hello,
On Mon, Nov 23, 2026 at 11:12:12PM +0000, TAKANO Mitsuhiro wrote:
> Hi Ian,
>
> 06/13 keeps a group that mixes a tool event with a kernel event from
> reaching the BUG_ON and the group read; I am not disputing that. What I
> want settled is whether such a group should be split or refused.
>
> The 06/13 commit message says:
>
> > Return false for PERF_PMU_TYPE_TOOL in perf_pmu__is_software(), matching
> > hwmon and drm PMUs, and ensure evsel__compute_group_pmu_name() only
> > substitutes perf_event_open PMU names for software and AUX events [...]
>
> I took the other approach: perf stat refuses a group that mixes a tool
> event with a kernel event (one that perf_event_open() opens), unless the
> group is weak and its leader is user_time or system_time. With that patch,
> perf stat rejects -e '{user_time,cycles}' with "A tool event cannot be
> grouped with kernel events: user_time" and exits with status 22, instead of
> printing a value for the tool event and "<not supported>" for the rest.
> This is v4 of "perf stat: Refuse a group mixing tool and kernel events":
>
> https://lore.kernel.org/all/20261122085947.3107661-1-takano32@gmail.com/
>
> In v4's test, the -a case expects a refusal that the cpu-map split in
> evlist__check_cpu_maps() makes impossible on a machine with more than one
> core PMU. Only the test needs to change; the refusal code does not. I
> will post v5 with that fix.
>
> The parser's split for events of another software PMU, and the split -a
> causes in evlist__check_cpu_maps(), are not what this is about, and I am
> not asking to change either. The -e '{user_time,cycles}' case is not a
> regression: perf stat opens it as one group today, the kernel rejects the
> cycles member with EBADF, and cycles prints "<not supported>". 06/13 would
> count both, as two groups. I would rather be told the group is refused,
> with a hint at the form that does work
> (-e '{cycles,instructions},user_time'), than have perf choose a grouping
> for me. That is a preference about what the braces mean, not a claim that
> 06/13 is broken, and it is yours to weigh. A warning would tell the user
> what happened, but the two groups would still start and stop separately,
> which is the part I cannot square with the braces. If a warning is what
> you have in mind, say so and I will take the refusal off the table.
>
> With 06/13 as posted, the tool event keeps its own PMU name, so the group is
> already split by the time perf stat's check runs. Moving my check before
> the parser regroups the events would refuse a group over members that -a
> would have taken out of it, so the check has to come after both the regroup
> and the split in evlist__check_cpu_maps(). If 06/13 keeps both changes --
> the one in perf_pmu__is_software() and the one in
> evsel__compute_group_pmu_name() -- the groups my test expects to be refused
> would be accepted instead.
>
> The refusal does not reintroduce the fd == -1 case 06/13 guards against:
> the check runs before perf_event_open(), so a group it refuses never reaches
> get_group_fd().
>
> On v3 of Hang's patch, which I posted for him, Namhyung wrote (2026-11-20,
> <awC_aZXD5FBGu4mO@google.com>):
>
> > I think grouping with tool events would cause more headaches. Probably
> > the simplest fix is to prohibit grouping.
>
> Namhyung, by "prohibit grouping", did you mean that perf stat should refuse
> such a group, or that it should count each event on its own and print a
> value for it? 06/13 does the second. When I wrote v4 I read you as asking
> for the first, and v4 refuses exactly those groups; a group of tool events
> alone, such as -e '{user_time,system_time}', is still accepted.
Right, but there's no reason to group tool events IIUC.
I was afraid that events like '{user_time,instructions,system_time,cycles}'
can complicate parsing and evlist handling. As they cannot be a group,
it'd be easier to reject them with a message instead of adding seemingly
unnecessary complexity.
Thanks,
Namhyung
>
> 07/13 ("perf evlist: Enable tool PMU events when starting a workload")
> fixes the enable_on_exec case my patch does not touch; I would like to see
> it land regardless of how this is settled.
>
> So which should it be: the split in 06/13, or the refusal in v4? If the
> split wins, I will withdraw v4. If the refusal wins, 06/13 would have to
> leave the PERF_PMU_TYPE_TOOL case alone in perf_pmu__is_software() and drop
> the PERF_PMU_KIND checks in evsel__compute_group_pmu_name().
>
> If you would rather leave it to Namhyung, I will go with whatever he says.
> I am asking you because 06/13 is your patch.
>
> Thanks,
> TAKANO Mitsuhiro
>
next prev parent reply other threads:[~2026-11-24 0:16 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 7:19 [PATCH v1 00/13] perf fixes: off-cpu, stat, tool PMU, bperf, and bpf-filter fixes Ian Rogers
2026-11-23 7:19 ` [PATCH v1 01/13] perf off-cpu: Bound callchain length in off_cpu_write() Ian Rogers
2026-11-23 7:19 ` [PATCH v1 02/13] perf off-cpu: Fix swapped PID and TID in direct off_cpu_dump() samples Ian Rogers
2026-11-23 7:19 ` [PATCH v1 03/13] libperf evlist: Recompute CPU map when an evsel goes system wide Ian Rogers
2026-11-23 7:19 ` [PATCH v1 04/13] perf stat: Give non-perf_event_open events unique IDs for stat record Ian Rogers
2026-11-23 7:19 ` [PATCH v1 05/13] perf stat: Preserve per-evsel CPU maps across stat record and report Ian Rogers
2026-11-23 17:12 ` Athira Rajeev
2026-11-23 7:19 ` [PATCH v1 06/13] perf pmu: Don't treat tool PMU as a kernel software PMU for event grouping Ian Rogers
2026-11-23 23:12 ` TAKANO Mitsuhiro
2026-11-24 0:16 ` Namhyung Kim [this message]
2026-11-23 7:19 ` [PATCH v1 07/13] perf evlist: Enable tool PMU events when starting a workload Ian Rogers
2026-11-23 7:19 ` [PATCH v1 08/13] perf stat: Respect the enabled time of exited user_time/system_time events Ian Rogers
2026-11-23 7:19 ` [PATCH v1 09/13] perf stat: Fix --bpf-counters with non-bperf, hybrid, and mixed events Ian Rogers
2026-11-23 7:19 ` [PATCH v1 10/13] perf bpf-filter: Fix bpf_link leak by using PERF_EVENT_IOC_SET_BPF Ian Rogers
2026-11-23 7:19 ` [PATCH v1 11/13] perf bpf-filter: Copy bpf_filters in evsel__clone() and close on evsel__close() Ian Rogers
2026-11-23 7:19 ` [PATCH v1 12/13] perf bpf-filter: Support BPF sample filters on tracepoint events Ian Rogers
2026-11-23 7:19 ` [PATCH v1 13/13] perf parse-events: Route non-field tracepoint filter terms to BPF filter Ian Rogers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=awTXdgY38s2bijW5@google.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=hang.zhengyang1010@gmail.com \
--cc=howardchu95@gmail.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=songliubraving@fb.com \
--cc=takano32@gmail.com \
--cc=thomas.falcon@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox