Alexander Shishkin <alexander.shish...@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.shish...@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