perf/core: Fix perf_sched_count derailment
authorAlexander Shishkin <alexander.shishkin@linux.intel.com>
Thu, 24 Mar 2016 11:14:53 +0000 (11:14 +0000)
committerSasha Levin <sasha.levin@oracle.com>
Thu, 24 Mar 2016 12:40:21 +0000 (08:40 -0400)
commit919e67a63aa967566a909f4f6e1c13f8e88cf76e
tree00934e59e15854aa43dbbebbb58ff0f256224be9
parent882f862db7f3509f055208b2e3e5bd263265a03b
perf/core: Fix perf_sched_count derailment

[ Upstream commit 927a5570855836e5d5859a80ce7e91e963545e8f ]

The error path in perf_event_open() is such that asking for a sampling
event on a PMU that doesn't generate interrupts will end up in dropping
the perf_sched_count even though it hasn't been incremented for this
event yet.

Given a sufficient amount of these calls, we'll end up disabling
scheduler's jump label even though we'd still have active events in the
system, thereby facilitating the arrival of the infernal regions upon us.

I'm fixing this by moving account_event() inside perf_event_alloc().

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: <stable@vger.kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: vince@deater.net
Link: http://lkml.kernel.org/r/1456917854-29427-1-git-send-email-alexander.shishkin@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: He Kuang <hekuang@huawei.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
kernel/events/core.c