Re: [PATCH v7 1/4] perf: Support PERF_SAMPLE_READ with inherit

From: Peter Zijlstra
Date: Mon Jun 10 2024 - 15:02:28 EST


On Fri, Jun 07, 2024 at 02:04:49PM +0000, Ben Gainey wrote:

> > 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.
> >
>
> As far as I can tell, you can mix events in a group with inconsistent
> values of PERF_SAMPLE_READ which means that doing it at the top level
> introduces an inconsistency/confusing behaviour since it makes the
> "thread-local-ness" of the read_format values a property of the event
> that caused the sample, rather than of the specific event to which the
> value belongs. The current implementation makes it a property of the
> specific event not the sample event. Specifically, when
> perf_output_read_group reads a child event that does not have
> PERF_SAMPLE_READ, the sample event must have PERF_SAMPLE_READ, meaning
> the child event will give the thread-local value even though it was not
> created as inherit+PERF_SAMPLE_READ
>
> I can either:
>
> * Keep it so that the perf_output_read_group uses per-event value for
> self

Having the lot be inconsistent seems bad.

> * Rework the deliver_sample_value in session.c to base its decision on
> the sample event rather than the specific event

The code as it exists seems to use the read_format from the event that
actually triggers the sample -- which makes sense. I would expect this
new thing to follow that.

Mixing inherit between events in a group gets you crap, but that's what
you asked for I suppose :-) But otherwise let the sampling event set the
format.

> * Forbid inconsistent PERF_SAMPLE_READ for events in a group

Not possible I think, you can have non-sampling events in a group.