All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "TAKANO Mitsuhiro" <takano32@gmail.com>,
	linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v12] perf stat: Refuse a group mixing tool and kernel events
Date: Wed, 02 Dec 2026 05:48:26 +0000	[thread overview]
Message-ID: <sashiko-outbox-244926@kernel.org> (raw)
In-Reply-To: <20261202053312.2695722-1-takano32@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] perf test stat+tool_group.sh: broken CPU 0 online regex and
  hybrid -C 0 check
--

commit dbb64e30a3f97e6dcaad829ae91a667bf57836b8
Author: TAKANO Mitsuhiro <takano32@gmail.com>

perf stat: Refuse a group mixing tool and kernel events

This commit makes perf stat reject event groups that mix non-perf_event_open
events (such as tool, hwmon, or drm events) with kernel events, updates
get_group_fd() and evsel enable/disable paths to handle members without file
descriptors, and adds a shell test covering tool event groups.

Link: https://lore.kernel.org/all/sashiko-outbox-227849@kernel.org/
Link: https://lore.kernel.org/all/sashiko-outbox-231330@kernel.org/
Link: https://lore.kernel.org/all/sashiko-outbox-232396@kernel.org/
Link: https://lore.kernel.org/all/20261111-tool-pmu-leader-v2-1-3faa0fb98c51@gmail.com/
Link: https://lore.kernel.org/all/awC_aZXD5FBGu4mO@google.com/
Link: https://lore.kernel.org/all/awTXdgY38s2bijW5@google.com/
Link: https://lore.kernel.org/all/20261123071913.653315-7-irogers@google.com/

> diff --git a/tools/perf/tests/shell/stat+tool_group.sh b/tools/perf/tests/shell/stat+tool_group.sh
> new file mode 100755
> index 0000000000000..4a2aae62321c0
> --- /dev/null
> +++ b/tools/perf/tests/shell/stat+tool_group.sh
> @@ -0,0 +1,386 @@

[ ... ]

> +# -C keeps the CPU map the user asked for.  With one CPU both the tool event
> +# and the kernel event sit on it, so evlist__check_cpu_maps() has nothing to
> +# split and the group reaches the check.  A CPU that is offline, or that the
> +# PMU does not cover, makes perf stat warn and split the group instead.
> +if grep -qE '(^|,)0(,|$)' /sys/devices/system/cpu/online 2>/dev/null; then
> +  refused '{cycles,duration_time}' duration_time -C 0
> +else
> +  echo "CPU 0 is not online, cannot test -C  [Skipped]"
> +  skipped=$((skipped + 1))
> +fi

[Severity: Medium]
Does this regex ever match when CPUs 0 and 1 are both online?

/sys/devices/system/cpu/online formats contiguous online CPUs as hyphenated
ranges such as 0-7, so '(^|,)0(,|$)' fails to match the hyphen after 0 and
skips the -C 0 test on any multi-CPU system where CPU 1 is also online
(matching '(^|,)0([,-]|$)' or checking /sys/devices/system/cpu/cpu0/online
would catch range output).

Also, on hybrid systems where the first sorted core PMU does not cover CPU 0
(for example, cpu_atom on CPUs 8-15 sorted before cpu_core on CPUs 0-7),
duration_time in '{cycles,duration_time}' is grouped with cpu_atom/cycles/
by the parser, and under -C 0 evlist__check_cpu_maps() splits the group
because cpu_atom does not cover CPU 0, causing perf stat to exit 0 instead
of 22.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202053312.2695722-1-takano32@gmail.com?part=1

      reply	other threads:[~2026-12-02  5:48 UTC|newest]

Thread overview: 28+ 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
2026-11-22  8:59   ` [PATCH v4] perf stat: Refuse a group mixing tool and kernel events TAKANO Mitsuhiro
2026-11-22  9:22     ` sashiko-bot
2026-11-24 13:56     ` [PATCH v5] " TAKANO Mitsuhiro
2026-11-24 14:18       ` sashiko-bot
2026-11-25  1:38       ` [PATCH v6] " TAKANO Mitsuhiro
2026-11-25  2:17         ` sashiko-bot
2026-11-25 13:38         ` [PATCH v7] " TAKANO Mitsuhiro
2026-11-25 13:56           ` sashiko-bot
2026-11-25 17:54           ` [PATCH v8] " TAKANO Mitsuhiro
2026-11-25 18:22             ` sashiko-bot
2026-11-25 22:27             ` [PATCH v9] " TAKANO Mitsuhiro
2026-11-25 22:59               ` sashiko-bot
2026-12-01  6:48               ` Ian Rogers
2026-12-01 14:08               ` [PATCH v10] " TAKANO Mitsuhiro
2026-12-01 14:27                 ` sashiko-bot
2026-12-01 23:55                 ` [PATCH v11] " TAKANO Mitsuhiro
2026-12-02  0:11                   ` sashiko-bot
2026-12-02  5:33                   ` [PATCH v12] " TAKANO Mitsuhiro
2026-12-02  5:48                     ` sashiko-bot [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=sashiko-outbox-244926@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --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.