lkml.org 
[lkml]   [2017]   [Aug]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] perf: Explain perf_sched_mutex
Date
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

\
 
 \ /
  Last update: 2017-08-29 16:09    [W:0.057 / U:1.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site