Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1742329 > unrolled thread

[tip:perf/core] perf/core: Explain perf_sched_mutex

Started bytip-bot for Alexander Shishkin <tipbot@zytor.com>
First post2017-09-29 22:20 +0200
Last post2017-09-29 22:20 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [tip:perf/core] perf/core: Explain perf_sched_mutex tip-bot for Alexander Shishkin <tipbot@zytor.com> - 2017-09-29 22:20 +0200

#1742329 — [tip:perf/core] perf/core: Explain perf_sched_mutex

Fromtip-bot for Alexander Shishkin <tipbot@zytor.com>
Date2017-09-29 22:20 +0200
Subject[tip:perf/core] perf/core: Explain perf_sched_mutex
Message-ID<uv9Vp-2wp-31@gated-at.bofh.it>
Commit-ID:  5bce9db1894c998c5b85a34036d679ea6517668f
Gitweb:     https://git.kernel.org/tip/5bce9db1894c998c5b85a34036d679ea6517668f
Author:     Alexander Shishkin <alexander.shishkin@linux.intel.com>
AuthorDate: Tue, 29 Aug 2017 17:01:03 +0300
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 29 Sep 2017 13:28:30 +0200

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>
---
 kernel/events/core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 6bc21e2..5ee6271 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -9394,6 +9394,11 @@ static void account_event(struct perf_event *event)
 		inc = true;
 
 	if (inc) {
+		/*
+		 * We need the mutex here because static_branch_enable()
+		 * must complete *before* the perf_sched_count increment
+		 * becomes visible.
+		 */
 		if (atomic_inc_not_zero(&perf_sched_count))
 			goto enabled;
 

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web