[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87h8wqxyft.fsf@ashishki-desk.ger.corp.intel.com>
Date: Tue, 29 Aug 2017 17:04:22 +0300
From: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
To: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Ingo Molnar <mingo@...hat.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] perf: Explain perf_sched_mutex
Alexander Shishkin <alexander.shishkin@...ux.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@...ux.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
Powered by blists - more mailing lists