Re: [PATCH 1/9] perf: Remove redundant parent context check from context_equiv

From: Peter Zijlstra
Date: Tue Sep 09 2014 - 06:20:13 EST


On Mon, Sep 08, 2014 at 06:45:24PM +0200, Jiri Olsa wrote:
> I just noticed that we initialize the child state with base parent
> state not the real (immediate) parent.. which is what we want IMO
>
> I wonder attached patch could fix the issue mentioned in:
> 1f9a726 perf: Do not allow optimized switch for non-cloned events
>
> now I need to recall what I used to test this ;-)

Ah, very nice! Yes this might just do it.

> ---
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index e4d6924..561a4ea 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -7794,6 +7794,7 @@ inherit_event(struct perf_event *parent_event,
> struct perf_event *group_leader,
> struct perf_event_context *child_ctx)
> {
> + enum perf_event_active_state parent_state = parent_event->state;
> struct perf_event *child_event;
> unsigned long flags;
>
> @@ -7827,7 +7828,7 @@ inherit_event(struct perf_event *parent_event,
> * not its attr.disabled bit. We hold the parent's mutex,
> * so we won't race with perf_event_{en, dis}able_family.
> */
> - if (parent_event->state >= PERF_EVENT_STATE_INACTIVE)
> + if (parent_state >= PERF_EVENT_STATE_INACTIVE)
> child_event->state = PERF_EVENT_STATE_INACTIVE;
> else
> child_event->state = PERF_EVENT_STATE_OFF;

Attachment: pgpwdhztvCWAI.pgp
Description: PGP signature