Re: [PATCH v3] perf/core: Set event shadow time for inactive events too

From: Peter Zijlstra
Date: Mon Dec 20 2021 - 04:40:02 EST


On Fri, Dec 10, 2021 at 10:59:49AM -0800, Namhyung Kim wrote:

> > You're doing that bpf-cgroup crud, right? Where exactly do you hook into
> > to do the counter reads?
>
> That's true but it doesn't use cgroup events actually. They are plain cpu
> events and BPF is called from a separate 'cgroup-switches' event to
> read out the counters.

Oh, right.

> > > Maybe because the event is enabled from the beginning.
> > > Then it might miss set_state/update_time at all.
> >
> > Even then, it's set to INACTIVE and any state change thereafter needs to
> > go through perf_event_set_state() and update the relevant timestamps.
>
> Right, but the problem happens when you read the event *before*
> any state change.

But the per-cpu event should be the simplest case ever, the cpu context
is *always* active, enabled time always runs.