diff options
| author | Alexander Shishkin <alexander.shishkin@linux.intel.com> | 2017-08-29 10:01:03 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2017-09-29 07:28:30 -0400 |
| commit | 5bce9db1894c998c5b85a34036d679ea6517668f (patch) | |
| tree | 98d531a881d66e722e2f275a43f4fc3681d21630 | |
| parent | 4c4de7d3c8383e3bf122cd84c61e7523df02b1ae (diff) | |
perf/core: Explain perf_sched_mutex
To clarify why atomic_inc_return(&perf_sched_events) is not sufficient and
a mutex is needed to order static branch enabling vs the atomic counter
increment, this adds a comment with a short explanation.
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20170829140103.6563-1-alexander.shishkin@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
| -rw-r--r-- | kernel/events/core.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c index 6bc21e202ae4..5ee62714f9a6 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
| @@ -9394,6 +9394,11 @@ static void account_event(struct perf_event *event) | |||
| 9394 | inc = true; | 9394 | inc = true; |
| 9395 | 9395 | ||
| 9396 | if (inc) { | 9396 | if (inc) { |
| 9397 | /* | ||
| 9398 | * We need the mutex here because static_branch_enable() | ||
| 9399 | * must complete *before* the perf_sched_count increment | ||
| 9400 | * becomes visible. | ||
| 9401 | */ | ||
| 9397 | if (atomic_inc_not_zero(&perf_sched_count)) | 9402 | if (atomic_inc_not_zero(&perf_sched_count)) |
| 9398 | goto enabled; | 9403 | goto enabled; |
| 9399 | 9404 | ||
