[PATCH 3/3] perf: Avoid cpu_hotplug_lock r-r recursion

From: Peter Zijlstra
Date: Tue Apr 18 2017 - 06:35:33 EST


There are two call-sites where using static_key results in recursing
on the cpu_hotplug_lock.

Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---
kernel/events/core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7785,7 +7785,7 @@ static int perf_swevent_init(struct perf
if (err)
return err;

- static_key_slow_inc(&perf_swevent_enabled[event_id]);
+ static_key_slow_inc_nohp(&perf_swevent_enabled[event_id]);
event->destroy = sw_perf_event_destroy;
}

@@ -9294,7 +9294,7 @@ static void account_event(struct perf_ev

mutex_lock(&perf_sched_mutex);
if (!atomic_read(&perf_sched_count)) {
- static_branch_enable(&perf_sched_events);
+ static_key_slow_inc_nohp(&perf_sched_events.key);
/*
* Guarantee that all CPUs observe they key change and
* call the perf scheduling hooks before proceeding to