From: Peter Zijlstra <peterz@infradead.org>
To: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
Andi Kleen <ak@linux.intel.com>,
Dapeng Mi <dapeng1.mi@linux.intel.com>,
Kan Liang <kan.liang@linux.intel.com>,
Thomas Falcon <thomas.falcon@intel.com>,
Stephane Eranian <eranian@google.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/2] perf/core: Add PERF_EVENT_STATE_ON to fix filtered event enabled time
Date: Thu, 3 Dec 2026 13:15:20 +0100 [thread overview]
Message-ID: <20261203121520.GN2883950@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <CAP-5=fXDz_Nrw0FmY+Dt6dnUkCeoZXTQbFL9PrzTJN_woK55VA@mail.gmail.com>
On Wed, Dec 02, 2026 at 10:24:26AM -0800, Ian Rogers wrote:
> > > - For event_sched_in() / merge_sched_in(), do you prefer keeping
> > > event_sched_in() reverting its speculative ACTIVE back to ON (with
> > > merge_sched_in() doing ON -> {ERROR,INACTIVE}), or would you rather
> > > see the state transition structured differently?
> >
> > I got rid of that speculative 'ON' thing, but I'm not convinced of the
> > result, see below.
>
> Replacing event_update_userpage()/group_update_userpage() in-place with
> event_set_inactive()/group_set_inactive() looks much cleaner than the v4
> detour. A few bugs I spotted in the draft patch above:
>
> 1. In group_sched_in()'s partial_tail loop:
> - `if (partial_tail) perf_event_set_state(event, PERF_EVENT_STATE_INACTIVE);`
> is missing `if (event->state <= PERF_EVENT_STATE_OFF) continue;`,
> so it will transition disabled (OFF) siblings in the tail to
> INACTIVE.
> - For a *pinned* group that fails on a sibling or commit_txn(),
> group_error: moves all siblings to PERF_EVENT_STATE_INACTIVE while
> merge_sched_in() only sets the leader to ERROR, leaving the
> siblings stuck in INACTIVE (so if the leader is later re-enabled on
> a filtered CPU or detached, those siblings remain INACTIVE).
> - Similarly, if __event_sched_out(group_event, ...) in group_error:
> consumes pending_disable and moves the leader to OFF, siblings
> already transitioned to INACTIVE earlier in the loop remain stuck
> in INACTIVE when merge_sched_in() exits at `state <= OFF`.
>
> Since merge_sched_in() already calls group_set_inactive(event) for
> flexible groups (and sets ERROR for pinned groups), having
> event_sched_in() and group_error: simply roll back to ON (no
> __event_sched_out() or partial_tail) avoids all three cases and keeps
> the single ON -> {ERROR, INACTIVE} transition in merge_sched_in().
Yeah, fair enough.
> 2. In __perf_event_enable(), without __perf_effective_state(), enabling
> a disabled sibling while its group leader is INACTIVE needs to match
> the leader's state:
>
> if (leader != event && leader->state != PERF_EVENT_STATE_ACTIVE) {
> if (leader->state == PERF_EVENT_STATE_INACTIVE)
> event_set_inactive(event); /* or set_state + userpage */
> return;
> }
>
> Otherwise the newly enabled sibling stays ON and accrues 0 enabled
> time while the leader is INACTIVE (until the next rotation, or
> indefinitely if counters are held by pinned events).
>
> Happy to fold those into your version and re-test (including hybrid +
> pinned-blocked/rollback tests) if this direction looks good to you.
Yeah, that seems sensible. Thanks!
prev parent reply other threads:[~2026-12-03 12:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 6:52 [PATCH v3 1/2] perf/core: Add PERF_EVENT_STATE_ON to fix filtered event enabled time Ian Rogers
2026-11-25 6:52 ` [PATCH v3 2/2] perf test: Add filtered event enabled time tests to event-times Ian Rogers
2026-12-02 14:13 ` Peter Zijlstra
2026-12-02 18:35 ` Ian Rogers
2026-12-03 7:53 ` Peter Zijlstra
2026-11-25 7:09 ` [PATCH v3 1/2] perf/core: Add PERF_EVENT_STATE_ON to fix filtered event enabled time sashiko-bot
2026-11-25 12:37 ` Peter Zijlstra
2026-11-25 13:02 ` Peter Zijlstra
2026-11-30 18:42 ` Ian Rogers
2026-12-01 9:18 ` Peter Zijlstra
2026-12-01 16:47 ` Ian Rogers
2026-12-02 10:17 ` Peter Zijlstra
2026-12-02 14:26 ` Peter Zijlstra
2026-12-02 18:24 ` Ian Rogers
2026-12-03 12:15 ` Peter Zijlstra [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=20261203121520.GN2883950@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=dapeng1.mi@linux.intel.com \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=thomas.falcon@intel.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