perf/core: Document some hotplug bits
authorPeter Zijlstra <[email protected]>
Tue, 8 Mar 2016 16:56:05 +0000 (17:56 +0100)
committerIngo Molnar <[email protected]>
Mon, 21 Mar 2016 08:35:29 +0000 (09:35 +0100)
Document some of the hotplug notifier usage.

Requested-by: Thomas Gleixner <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Brian Gerst <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Denys Vlasenko <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Vince Weaver <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
kernel/events/core.c

index 43e35faf576ed2e712a97b11eae38ec8fb64cefa..de24fbce52774f1d0625c8c0c7c73c3368061bf7 100644 (file)
@@ -9449,10 +9449,29 @@ perf_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu)
        switch (action & ~CPU_TASKS_FROZEN) {
 
        case CPU_UP_PREPARE:
+               /*
+                * This must be done before the CPU comes alive, because the
+                * moment we can run tasks we can encounter (software) events.
+                *
+                * Specifically, someone can have inherited events on kthreadd
+                * or a pre-existing worker thread that gets re-bound.
+                */
                perf_event_init_cpu(cpu);
                break;
 
        case CPU_DOWN_PREPARE:
+               /*
+                * This must be done before the CPU dies because after that an
+                * active event might want to IPI the CPU and that'll not work
+                * so great for dead CPUs.
+                *
+                * XXX smp_call_function_single() return -ENXIO without a warn
+                * so we could possibly deal with this.
+                *
+                * This is safe against new events arriving because
+                * sys_perf_event_open() serializes against hotplug using
+                * get_online_cpus().
+                */
                perf_event_exit_cpu(cpu);
                break;
        default: