]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
timers/migration: Prevent from lockdep false positive warning
authorFrederic Weisbecker <frederic@kernel.org>
Tue, 23 Dec 2025 14:12:46 +0000 (15:12 +0100)
committerFrederic Weisbecker <frederic@kernel.org>
Tue, 3 Feb 2026 14:23:33 +0000 (15:23 +0100)
Testing housekeeping_cpu() will soon require that either the RCU "lock"
is held or the cpuset mutex.

When CPUs get isolated through cpuset, the change is propagated to
timer migration such that isolation is also performed from the migration
tree. However that propagation is done using workqueue which tests if
the target is actually isolated before proceeding.

Lockdep doesn't know that the workqueue caller holds cpuset mutex and
that it waits for the work, making the housekeeping cpumask read safe.

Shut down the future warning by removing this test. It is unecessary
beyond hotplug, the workqueue is already targeted towards isolated CPUs.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Cc: Gabriele Monaco <gmonaco@redhat.com>
kernel/time/timer_migration.c

index 18dda1aa782d50780c7af32f5c5873f1c1dafab1..3879575a4975355aec2c2cf36f1e3aef5043ac97 100644 (file)
@@ -1497,7 +1497,7 @@ static int tmigr_clear_cpu_available(unsigned int cpu)
        return 0;
 }
 
-static int tmigr_set_cpu_available(unsigned int cpu)
+static int __tmigr_set_cpu_available(unsigned int cpu)
 {
        struct tmigr_cpu *tmc = this_cpu_ptr(&tmigr_cpu);
 
@@ -1505,9 +1505,6 @@ static int tmigr_set_cpu_available(unsigned int cpu)
        if (WARN_ON_ONCE(!tmc->tmgroup))
                return -EINVAL;
 
-       if (tmigr_is_isolated(cpu))
-               return 0;
-
        guard(mutex)(&tmigr_available_mutex);
 
        cpumask_set_cpu(cpu, tmigr_available_cpumask);
@@ -1523,6 +1520,14 @@ static int tmigr_set_cpu_available(unsigned int cpu)
        return 0;
 }
 
+static int tmigr_set_cpu_available(unsigned int cpu)
+{
+       if (tmigr_is_isolated(cpu))
+               return 0;
+
+       return __tmigr_set_cpu_available(cpu);
+}
+
 static void tmigr_cpu_isolate(struct work_struct *ignored)
 {
        tmigr_clear_cpu_available(smp_processor_id());
@@ -1530,7 +1535,12 @@ static void tmigr_cpu_isolate(struct work_struct *ignored)
 
 static void tmigr_cpu_unisolate(struct work_struct *ignored)
 {
-       tmigr_set_cpu_available(smp_processor_id());
+       /*
+        * Don't call tmigr_is_isolated() ->housekeeping_cpu() directly because
+        * the cpuset mutex is correctly held by the workqueue caller but lockdep
+        * doesn't know that.
+        */
+       __tmigr_set_cpu_available(smp_processor_id());
 }
 
 /**