]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf: Remove too early and redundant CPU hotplug handling
authorFrederic Weisbecker <frederic@kernel.org>
Thu, 24 Apr 2025 16:11:27 +0000 (18:11 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 8 May 2025 19:50:19 +0000 (21:50 +0200)
The CPU hotplug handlers are called twice: at prepare and online stage.

Their role is to:

1) Enable/disable a CPU context. This is irrelevant and even buggy at
   the prepare stage because the CPU is still offline. On early
   secondary CPU up, creating an event attached to that CPU might
   silently fail because the CPU context is observed as online but the
   context installation's IPI failure is ignored.

2) Update the scope cpumasks and re-migrate the events accordingly in
   the CPU down case. This is irrelevant at the prepare stage.

3) Remove the events attached to the context of the offlining CPU. It
   even uses an (unnecessary) IPI for it. This is also irrelevant at the
   prepare stage.

Also none of the *_PREPARE and *_STARTING architecture perf related CPU
hotplug callbacks rely on CPUHP_PERF_PREPARE.

CPUHP_AP_PERF_ONLINE is enough and the right place to perform the work.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20250424161128.29176-4-frederic@kernel.org
include/linux/cpuhotplug.h
kernel/cpu.c

index 1987400000b417a30d5ce5bccfbf25ff9f1338ad..df366ee15456bba56c581d482f98a5b9d26211d5 100644 (file)
@@ -60,7 +60,6 @@ enum cpuhp_state {
        /* PREPARE section invoked on a control CPU */
        CPUHP_OFFLINE = 0,
        CPUHP_CREATE_THREADS,
-       CPUHP_PERF_PREPARE,
        CPUHP_PERF_X86_PREPARE,
        CPUHP_PERF_X86_AMD_UNCORE_PREP,
        CPUHP_PERF_POWER,
index b08bb34b1718ad0a8f80854bc65e25e36546e2aa..a59e009e0be46d37880d2943ebd3e828c5f7d8f3 100644 (file)
@@ -2069,11 +2069,6 @@ static struct cpuhp_step cpuhp_hp_states[] = {
                .teardown.single        = NULL,
                .cant_stop              = true,
        },
-       [CPUHP_PERF_PREPARE] = {
-               .name                   = "perf:prepare",
-               .startup.single         = perf_event_init_cpu,
-               .teardown.single        = perf_event_exit_cpu,
-       },
        [CPUHP_RANDOM_PREPARE] = {
                .name                   = "random:prepare",
                .startup.single         = random_prepare_cpu,