]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rcu/exp: Warn on QS requested on dying CPU
authorFrederic Weisbecker <frederic@kernel.org>
Tue, 29 Apr 2025 13:43:03 +0000 (15:43 +0200)
committerNeeraj Upadhyay (AMD) <neeraj.upadhyay@kernel.org>
Tue, 8 Jul 2025 17:51:13 +0000 (23:21 +0530)
It is not possible to send an IPI to a dying CPU that has passed the
CPUHP_TEARDOWN_CPU stage. Remaining unhandled IPIs are handled later at
CPUHP_AP_SMPCFD_DYING stage by stop machine. This is the last
opportunity for RCU exp handler to request an expedited quiescent state.
And the upcoming final context switch between stop machine and idle must
have reported the requested context switch.

Therefore, it should not be possible to observe a pending requested
expedited quiescent state when RCU finally stops watching the outgoing
CPU. Once IPIs aren't possible anymore, the QS for the target CPU will
be reported on its behalf by the RCU exp kworker.

Provide an assertion to verify those expectations.

Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
Signed-off-by: Neeraj Upadhyay (AMD) <neeraj.upadhyay@kernel.org>
kernel/rcu/tree.c

index 0bda23fec690961b286dbe21c0cd1a470ef77ef4..00c182b3f978cbd9be90321edb601216b8ebead5 100644 (file)
@@ -4356,6 +4356,12 @@ void rcutree_report_cpu_dead(void)
         * may introduce a new READ-side while it is actually off the QS masks.
         */
        lockdep_assert_irqs_disabled();
+       /*
+        * CPUHP_AP_SMPCFD_DYING was the last call for rcu_exp_handler() execution.
+        * The requested QS must have been reported on the last context switch
+        * from stop machine to idle.
+        */
+       WARN_ON_ONCE(rdp->cpu_no_qs.b.exp);
        // Do any dangling deferred wakeups.
        do_nocb_deferred_wakeup(rdp);