Linux Perf Users
 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 v3] perf stat: Start tool events when enable_on_exec is used
Date: Fri, 23 Oct 2026 10:23:24 +0000	[thread overview]
Message-ID: <sashiko-outbox-182676@kernel.org> (raw)
In-Reply-To: <20261023101256.1752713-1-takano32@gmail.com>

> When perf stat runs a workload, target__enable_on_exec() is true and the
> tool events are left to the kernel to start on exec.  Tool events are
> however emulated in perf (duration_time, user_time, system_time,
> num_cpus) and have nothing in the kernel to start them, so they stay
> disabled and are read as zero.
> 
> For duration_time this makes CPUs_utilized divide by zero, and plain
> "perf stat" prints "nan CPUs":
> 
>   $ perf stat -e task-clock,duration_time -- sleep 0.1
>                0      duration_time
> 
> Start the tool events explicitly in that case.  They are started through
> evsel__tool_pmu_enable() rather than evsel__enable(), because the latter
> also enables the members of a mixed PMU group, and those cannot be used
> here: get_group_fd() passes the leader's descriptor to
> sys_perf_event_open(), which fails with EINVAL for a userspace PMU
> leader, so the members end up unsupported with core.fd released.  Only
> the tool event itself is started; the kernel starts the members of a
> group it can open.
> 
> Skip the events that failed to open, the same way the evlist and the
> counter read paths skip them, so a tool event that never opened is not
> started and then read through a NULL descriptor.
> 
> Fixes: 0b18bced5444 ("perf tool_pmu: Make tool PMU events respect enable/disable")
> Assisted-by: LLM
> 

Sashiko has reviewed this patch and found no issues.

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


      reply	other threads:[~2026-10-23 10:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22  2:49 [PATCH] perf stat: Start tool events when enable_on_exec is used TAKANO Mitsuhiro
2026-10-22  3:14 ` sashiko-bot
2026-10-23  8:55 ` [PATCH v2] " TAKANO Mitsuhiro
2026-10-23  9:22   ` sashiko-bot
2026-10-23 10:12   ` [PATCH v3] " TAKANO Mitsuhiro
2026-10-23 10:23     ` 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-182676@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox