mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] perf: Explain perf_sched_mutex
@ 2017-08-29 14:01 Alexander Shishkin
  2017-08-29 14:04 ` Alexander Shishkin
  2017-09-29 20:07 ` [tip:perf/core] perf/core: " tip-bot for Alexander Shishkin
  0 siblings, 2 replies; 3+ messages in thread
From: Alexander Shishkin @ 2017-08-29 14:01 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: Ingo Molnar, linux-kernel, Alexander Shishkin

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 an short explanation.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
---
 kernel/events/core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index efe09b8c38..2c8719b635 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -9569,6 +9569,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;
 
-- 
2.14.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf: Explain perf_sched_mutex
  2017-08-29 14:01 [PATCH] perf: Explain perf_sched_mutex Alexander Shishkin
@ 2017-08-29 14:04 ` Alexander Shishkin
  2017-09-29 20:07 ` [tip:perf/core] perf/core: " tip-bot for Alexander Shishkin
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander Shishkin @ 2017-08-29 14:04 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: Ingo Molnar, linux-kernel

Alexander Shishkin <alexander.shishkin@linux.intel.com> writes:

> 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 an short explanation.

"with a short explanation", sigh

>
> Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> ---
>  kernel/events/core.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index efe09b8c38..2c8719b635 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -9569,6 +9569,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;
>  
> -- 
> 2.14.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:perf/core] perf/core: Explain perf_sched_mutex
  2017-08-29 14:01 [PATCH] perf: Explain perf_sched_mutex Alexander Shishkin
  2017-08-29 14:04 ` Alexander Shishkin
@ 2017-09-29 20:07 ` tip-bot for Alexander Shishkin
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Alexander Shishkin @ 2017-09-29 20:07 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, linux-kernel, tglx, peterz, alexander.shishkin, torvalds, mingo

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;
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-09-29 20:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-29 14:01 [PATCH] perf: Explain perf_sched_mutex Alexander Shishkin
2017-08-29 14:04 ` Alexander Shishkin
2017-09-29 20:07 ` [tip:perf/core] perf/core: " tip-bot for Alexander Shishkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®