From: Peter Zijlstra <peterz@infradead.org>
To: Ben Gainey <Ben.Gainey@arm.com>
Cc: "alexander.shishkin@linux.intel.com"
<alexander.shishkin@linux.intel.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Mark Rutland <Mark.Rutland@arm.com>,
"acme@kernel.org" <acme@kernel.org>,
"mingo@redhat.com" <mingo@redhat.com>,
James Clark <James.Clark@arm.com>,
"adrian.hunter@intel.com" <adrian.hunter@intel.com>,
"namhyung@kernel.org" <namhyung@kernel.org>,
"irogers@google.com" <irogers@google.com>,
"jolsa@kernel.org" <jolsa@kernel.org>,
"linux-perf-users@vger.kernel.org"
<linux-perf-users@vger.kernel.org>
Subject: Re: [PATCH v7 1/4] perf: Support PERF_SAMPLE_READ with inherit
Date: Fri, 7 Jun 2024 13:02:14 +0200 [thread overview]
Message-ID: <20240607110214.GQ8774@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <451afb8eb03f1519c482a84a6c1cbd1e62222988.camel@arm.com>
On Fri, Jun 07, 2024 at 10:16:15AM +0000, Ben Gainey wrote:
> > > @@ -3532,11 +3544,18 @@ perf_event_context_sched_out(struct
> > > task_struct *task, struct task_struct *next)
> > > perf_ctx_disable(ctx, false);
> > >
> > > /* PMIs are disabled; ctx->nr_pending is stable. */
> > > - if (local_read(&ctx->nr_pending) ||
> > > + if (ctx->nr_inherit_read ||
> > > + next_ctx->nr_inherit_read ||
> > > + local_read(&ctx->nr_pending) ||
> > > local_read(&next_ctx->nr_pending)) {
> >
> > This seems unfortunate, nr_pending and nr_inherit_read are both used
> > exclusively to inhibit this context switch optimization. Surely they
> > can
> > share the exact same counter.
> >
> > That is, rename nr_pending and use it for both?
>
> Sure, how about "nr_no_switch_fast" ?
Yeah, I suppose.
> Sure, presumably you are happy with just calling
> "perf_event_count(event, false)" everywhere it is currently used,
> rather than renaming it to something shorter and keeping the two
> functions?
Yeah, there aren't *that* many instances. Your current patch already
touches them all anyway.
> > That is, I would really rather you had:
> >
> > static inline u64 perf_event_count(struct perf_event *event, bool
> > self)
> > {
> > if (self)
> > return local64_read(&event->count);
> >
> > return local64_read(&event->count) + local64_read(&event-
> > >child_count);
> > }
> >
> > And then actually use that argument as intended.
>
>
> Fair point.
>
> I was trying to avoid the 3 subsequent uses all having to repeat
> "from_sample && has_inherit_and_sample_read(&event->attr)", which feels
> a bit of a pit-trappy.
>
> I suppose I could pull that into a "use_self_value(from_sample,event)"?
IIRC they all originate in a single location around perf_output_read(),
that already has the event and could easily 'correct' the semantic
meaning by doing the above once or so.
> >
> > > @@ -7205,13 +7232,14 @@ void perf_event__output_id_sample(struct
> > > perf_event *event,
> > >
> > > static void perf_output_read_one(struct perf_output_handle
> > > *handle,
> > > struct perf_event *event,
> > > - u64 enabled, u64 running)
> > > + u64 enabled, u64 running,
> > > + bool from_sample)
> > > {
> > > u64 read_format = event->attr.read_format;
> > > u64 values[5];
> > > int n = 0;
> > >
> > > - values[n++] = perf_event_count(event);
> > > + values[n++] = perf_event_count(event, from_sample);
> >
> > ...observe the fail... from_sample != self-value-only
>
> By fail you are referring to the difference in names?
The difference in meaning, one is from-sample, the other is self-value.
Per the extra condition squirrelled away they are not equivalent.
next prev parent reply other threads:[~2024-06-07 11:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-06 14:40 [PATCH v7 0/4] perf: Support PERF_SAMPLE_READ with inherit Ben Gainey
2024-06-06 14:40 ` [PATCH v7 1/4] " Ben Gainey
2024-06-07 9:32 ` Peter Zijlstra
2024-06-07 10:16 ` Ben Gainey
2024-06-07 11:02 ` Peter Zijlstra [this message]
2024-06-07 14:04 ` Ben Gainey
2024-06-10 19:01 ` Peter Zijlstra
2024-06-06 14:40 ` [PATCH v7 2/4] tools/perf: Track where perf_sample_ids need per-thread periods Ben Gainey
2024-06-06 14:40 ` [PATCH v7 3/4] tools/perf: Correctly calculate sample period for inherited SAMPLE_READ values Ben Gainey
2024-06-06 14:40 ` [PATCH v7 4/4] tools/perf: Allow inherit + PERF_SAMPLE_READ when opening events Ben Gainey
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=20240607110214.GQ8774@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=Ben.Gainey@arm.com \
--cc=James.Clark@arm.com \
--cc=Mark.Rutland@arm.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.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