From: Jiri Olsa Date: Tue, 24 Jun 2014 08:20:25 +0000 (+0200) Subject: perf: Do not allow optimized switch for non-cloned events X-Git-Tag: upstream/snapshot3+hdmi~2004 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git;a=commitdiff_plain;h=a874a875b978fc05d0e58a514e714c1719a0bfb3 perf: Do not allow optimized switch for non-cloned events commit 1f9a7268c67f0290837aada443d28fd953ddca90 upstream. The context check in perf_event_context_sched_out allows non-cloned context to be part of the optimized schedule out switch. This could move non-cloned context into another workload child. Once this child exits, the context is closed and leaves all original (parent) events in closed state. Any other new cloned event will have closed state and not measure anything. And probably causing other odd bugs. Signed-off-by: Jiri Olsa Signed-off-by: Peter Zijlstra Cc: Arnaldo Carvalho de Melo Cc: Paul Mackerras Cc: Frederic Weisbecker Cc: Namhyung Kim Cc: Paul Mackerras Cc: Corey Ashford Cc: David Ahern Cc: Jiri Olsa Cc: Linus Torvalds Link: http://lkml.kernel.org/r/1403598026-2310-2-git-send-email-jolsa@kernel.org Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- diff --git a/kernel/events/core.c b/kernel/events/core.c index 0e7fea7..f774e93 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -2311,7 +2311,7 @@ static void perf_event_context_sched_out(struct task_struct *task, int ctxn, next_parent = rcu_dereference(next_ctx->parent_ctx); /* If neither context have a parent context; they cannot be clones. */ - if (!parent && !next_parent) + if (!parent || !next_parent) goto unlock; if (next_parent == ctx || next_ctx == parent || next_parent == parent) {