From: TAKANO Mitsuhiro <takano32@gmail.com>
To: Namhyung Kim <namhyung@kernel.org>
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,
TAKANO Mitsuhiro <takano32@gmail.com>
Subject: Re: [PATCH v3] perf stat: Count kernel events in a group led by a tool event
Date: Thu, 19 Nov 2026 10:08:38 +0000 [thread overview]
Message-ID: <179508291800.2785063.13205692423397372334@gmail.com> (raw)
In-Reply-To: <av6t6M0fUYdtXDEu@google.com>
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.
Thanks,
TAKANO
prev parent reply other threads:[~2026-11-19 10:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 6:04 [PATCH v2] " Hang Zhengyang via B4 Relay
2026-11-11 11:06 ` [PATCH v3] " TAKANO Mitsuhiro
[not found] ` <sashiko-outbox-208886@kernel.org>
2026-11-12 3:49 ` Hang Zhengyang
2026-11-19 8:06 ` Namhyung Kim
2026-11-19 10:08 ` TAKANO Mitsuhiro [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=179508291800.2785063.13205692423397372334@gmail.com \
--to=takano32@gmail.com \
--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=namhyung@kernel.org \
--cc=peterz@infradead.org \
/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
all inboxes | Powered by JetHome®