Linux Perf Users
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: "Chengdong Li(李成栋)" <chengdongli@optimatist.com>
Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
	namhyung@kernel.org, alexander.shishkin@linux.intel.com,
	jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com,
	kan.liang@linux.intel.com, linux-perf-users@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf/core: Improve arguments checking of inherited per-task counters when sampling.
Date: Wed, 27 Aug 2025 11:44:52 +0100	[thread overview]
Message-ID: <aK7hpARhr5RxVveA@J2N7QTR9R3> (raw)
In-Reply-To: <D1D50EA0-EFC3-4FAB-A898-A61BD081B527@optimatist.com>

On Tue, Aug 19, 2025 at 09:31:46PM +0800, Chengdong Li(李成栋) wrote:
> Hi Mark,
> 
> On 2025/8/19, 18:26, "Mark Rutland" <mark.rutland@arm.com <mailto:mark.rutland@arm.com>> wrote:
> 
> 
> >On Thu, Aug 14, 2025 at 07:06:25PM +0800, Chengdong Li wrote:
> >> It's not allowed to mmap() of inherited per-task counters with CPU ==
> >> -1, this would create a performance issue. But it is not friendly to
> >> developers as current implementation postponed the arguments checking to
> >> perf_mmap(), developer can get an -EINVAL from mmap() but without
> >> any previous error returned from perf_event_open().
> >>
> >> This patch improves it by moving the arguments checking from perf_mmap()
> >> to perf_event_open().
> >
> >Why is that an improvement?
> >
> >IIUC before this patch, it would be possible to read() the event,
> >whereas now the event cannot be opened at all.
> 
> That's true, could you provide a use case that using sampling mode but without
> ring buffer? From my best knowledge, I think counting mode is more suitable
> for read() only.

I could be mistaken, but IIRC the RR folk were using sampling mode to
get notifications upon each sample/overflow, but they don't really care
about the sample itself. They might not care about inherited counters
for that workload, but I'm fairly sure that sampling without mmap is a
real (albeit unusual) use-case.

> >AFAICT this is removing functionality people could legitimately use, so
> >this doesn't seem like an improvement.
> 
> The problem is that using inherit per-task counter with sampling mode would lead
> developer hard to debug why mmap() returns -EINVAL. There is not error returned from
> perf_event_open(), everything done seems right but failed at mmap(), and there is
> no clue in man open_event_open() as well.

Ok, but presumably they do that mmap() shortly after doing the relavant
perf_event_open() calls?

When do people hit this in practice? Do they actually see this when
deploying a workload, or just when developing code that uses sampling?

Mark.

  reply	other threads:[~2025-08-27 10:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-14 11:06 [PATCH] perf/core: Improve arguments checking of inherited per-task counters when sampling Chengdong Li
2025-08-19 10:26 ` Mark Rutland
2025-08-19 13:31   ` Chengdong Li(李成栋)
2025-08-27 10:44     ` Mark Rutland [this message]
2025-08-20  7:17 ` kernel test robot

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=aK7hpARhr5RxVveA@J2N7QTR9R3 \
    --to=mark.rutland@arm.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=chengdongli@optimatist.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --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