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

From: Peter Zijlstra
Date: Mon Dec 20 2021 - 04:55:22 EST


On Mon, Dec 20, 2021 at 10:30:34AM +0100, Peter Zijlstra wrote:
> On Sat, Dec 18, 2021 at 09:09:05AM +0000, Song Liu wrote:

> > Unfortunately, this change bring the bug back. For time_enabled in rdpmc
> > case to work properly, we have to touch all the enabled but not running
> > events, right?
>
> Ohh.. argh. I think I see why, it looses the context time enable edge,
> and because this is all strictly per-event in the uapi (there is no ctx
> representation) it can't be cured by improving ctx time handling :/
>
> Bah, I so hate this.

For now I've added this then ...

+/*
+ * Because the userpage is strictly per-event (there is no concept of context,
+ * so there cannot be a context indirection), every userpage must be updated
+ * when context time starts :-(
+ *
+ * IOW, we must not miss EVENT_TIME edges.
+ */
static inline bool event_update_userpage(struct perf_event *event)


But that same is not true for perf_event_read_local(), that *has* access
to the context and so must be able to DTRT.