Re: [PATCH v3 1/2] perf/core: Add PERF_EVENT_STATE_ON to fix filtered event enabled time

From: Peter Zijlstra

Date: Tue Dec 01 2026 - 04:19:17 EST


On Mon, Nov 30, 2026 at 10:42:55AM -0800, Ian Rogers wrote:
> On Wed, Nov 25, 2026 at 5:02 AM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> >
> > On Wed, Nov 25, 2026 at 01:37:12PM +0100, Peter Zijlstra wrote:
> > > On Tue, Nov 24, 2026 at 10:52:28PM -0800, Ian Rogers wrote:
> > > > @@ -4134,6 +4154,21 @@ struct merge_sched_data {
> > > > enum event_type_t event_type;
> > > > };
> > > >
> > > > +static void group_set_inactive(struct perf_event *group_event)
> > > > +{
> > > > + struct perf_event *sibling;
> > > > +
> > > > + perf_event_set_state(group_event, PERF_EVENT_STATE_INACTIVE);
> > > > +
> > > > + for_each_sibling_event(sibling, group_event) {
> > > > + if (sibling->state == PERF_EVENT_STATE_ON)
> > > > + perf_event_set_state(sibling, PERF_EVENT_STATE_INACTIVE);
> > > > + }
> > > > +
> > > > + list_add_tail(&group_event->active_list,
> > > > + &group_event->pmu_ctx->flexible_inactive);
> > > > +}
> >
> > This whole thing looks dodgy as well. This feels like
> > __perf_effective_state() needs an update or something.
>
>
> Thanks for the review, Peter! I've sent v4 addressing all of these:
> https://lore.kernel.org/linux-perf-users/8b61be11e09ae7f663253cde769eff5456ebc263.1796063587.git.irogers@xxxxxxxxxx/
>
> - Took your state diagram and comment cleanup in perf_event.h.
> - Updated __perf_effective_state() and perf_event_set_state() so enabled
> (ON) siblings inherit INACTIVE from their group leader, removing
> group_set_inactive() (while promoting ON siblings to INACTIVE on
> flexible_inactive if an INACTIVE leader is detached).
> - De-duplicated the pending_disable path in event_sched_out().
> - Updated merge_sched_in() to branch directly on group_can_go_on() and
> group_sched_in() rather than testing event->state == ON. In
> event_sched_in(), reverting the speculative ACTIVE back to ON keeps
> siblings in ON and matches group_error: rollback so merge_sched_in()
> remains the single place transitioning ON -> {ERROR, INACTIVE}.
>

I've got to ask; are you vibing this? There seem to be random changes in
the patch not listed above that make review harder than it wants to be.

Eg. there is now a shortcut in group_sched_out() that avoids iterating
the siblings when !active. This then leads to other weirdness.