perf/core: Convert to hotplug state machine
[cascardo/linux.git] / kernel / cpu.c
index d948e44..3705d90 100644 (file)
@@ -517,6 +517,13 @@ static int cpuhp_invoke_ap_callback(int cpu, enum cpuhp_state state,
        if (!cpu_online(cpu))
                return 0;
 
+       /*
+        * If we are up and running, use the hotplug thread. For early calls
+        * we invoke the thread function directly.
+        */
+       if (!st->thread)
+               return cpuhp_invoke_callback(cpu, state, cb);
+
        st->cb_state = state;
        st->cb = cb;
        /*
@@ -1173,6 +1180,11 @@ static struct cpuhp_step cpuhp_bp_states[] = {
                .teardown               = NULL,
                .cant_stop              = true,
        },
+       [CPUHP_PERF_PREPARE] = {
+               .name = "perf prepare",
+               .startup = perf_event_init_cpu,
+               .teardown = perf_event_exit_cpu,
+       },
        /*
         * Preparatory and dead notifiers. Will be replaced once the notifiers
         * are converted to states.
@@ -1201,6 +1213,8 @@ static struct cpuhp_step cpuhp_bp_states[] = {
                .teardown               = takedown_cpu,
                .cant_stop              = true,
        },
+#else
+       [CPUHP_BRINGUP_CPU] = { },
 #endif
 };
 
@@ -1248,6 +1262,12 @@ static struct cpuhp_step cpuhp_ap_states[] = {
                .startup                = smpboot_unpark_threads,
                .teardown               = NULL,
        },
+       [CPUHP_AP_PERF_ONLINE] = {
+               .name = "perf online",
+               .startup = perf_event_init_cpu,
+               .teardown = perf_event_exit_cpu,
+       },
+
        /*
         * Online/down_prepare notifiers. Will be removed once the notifiers
         * are converted to states.