From: Namhyung Kim <namhyung@kernel.org>
To: TAKANO Mitsuhiro <takano32@gmail.com>
Cc: Ian Rogers <irogers@google.com>,
Hang Zhengyang <hang.zhengyang1010@gmail.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] perf stat: Count kernel events in a group led by a tool event
Date: Fri, 20 Nov 2026 13:45:13 -0800 [thread overview]
Message-ID: <awC_aZXD5FBGu4mO@google.com> (raw)
In-Reply-To: <179508291800.2785063.13205692423397372334@gmail.com>
On Thu, Nov 19, 2026 at 10:08:38AM +0000, TAKANO Mitsuhiro wrote:
> Hi Namhyung,
>
> > I think it's better to make the first non-tool event as a leader
>
> I agree, and I think that is where this ends up. What stops me from
> doing it in this patch is the group read: with a kernel event as the
> leader, evsel__group_read_nr_members() still counts a tool event member,
> while the kernel knows nothing about it (a tool event is not opened
> through perf_event_open, it reads /proc/stat) and returns one entry
> fewer. evsel__process_group_data() then rejects the read with -EINVAL
> and the kernel events of that group come out as <not counted> as well.
> The smallest version of that is a few lines, but it changes what every
> group with a tool event member prints, so it wants its own test and its
> own commit rather than riding along with the EBADF fix.
>
> > but I'm afraid it'd make evlist management complex
>
> v3 leaves the group structure alone: no new evlist entry, nr_members
> unchanged, and evsel->leader stays whoever it already was. What changes
> is how the members are opened:
>
> - get_group_fd(): with group_fd = -1 instead of the tool event's
> /proc/stat fd, or -2 when the leader failed to open, the same -2 the
> skipped-leader case already returns for a broken group;
> - create_perf_stat_counter(): a kernel event member is opened disabled,
> as a leader is, so that it starts with the workload, and
> PERF_FORMAT_GROUP is not requested for the members - read_format is
> per fd, and GROUP is what would send each member's read down the
> group path that only a leader can take. PERF_FORMAT_ID goes with it:
> without a group read nothing demuxes ids.
>
> The cost is real and the changelog states it: in -e '{user_time,a,b}',
> a and b no longer share an on/off window.
>
> Two things this does not change, both of which happen without the patch:
> a tool event member still counts through a -D / --control window, and a
> tool event leader under enable_on_exec is still not started by anything -
> that is what "perf stat: Start tool events when enable_on_exec is used"
> is for.
>
> Either way the leader move is a separate series; I can post it once the
> direction is settled.
I think grouping with tool events would cause more headaches. Probably
the simplest fix is to prohibit grouping.
Thanks,
Namhyung
prev parent reply other threads:[~2026-11-20 21:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 6:04 [PATCH v2] perf stat: Count kernel events in a group led by a tool event Hang Zhengyang via B4 Relay
2026-11-11 6:04 ` Hang Zhengyang
2026-11-11 6:18 ` sashiko-bot
2026-11-11 11:06 ` [PATCH v3] " TAKANO Mitsuhiro
2026-11-11 11:33 ` sashiko-bot
2026-11-12 3:49 ` Hang Zhengyang
2026-11-19 8:06 ` Namhyung Kim
2026-11-19 10:08 ` TAKANO Mitsuhiro
2026-11-20 21:45 ` Namhyung Kim [this message]
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=awC_aZXD5FBGu4mO@google.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=hang.zhengyang1010@gmail.com \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=takano32@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.