]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
rcu/tasks: Check processor-ID assumptions
authorPaul E. McKenney <paulmck@kernel.org>
Fri, 2 Aug 2024 00:34:21 +0000 (17:34 -0700)
committerNeeraj Upadhyay <neeraj.upadhyay@kernel.org>
Wed, 14 Aug 2024 11:18:10 +0000 (16:48 +0530)
The current mapping of smp_processor_id() to a CPU processing Tasks-RCU
callbacks makes some assumptions about layout.  This commit therefore
adds a WARN_ON() to check these assumptions.

[ neeraj.upadhyay: Replace nr_cpu_ids with rcu_task_cpu_ids. ]

Signed-off-by: "Paul E. McKenney" <paulmck@kernel.org>
Signed-off-by: Neeraj Upadhyay <neeraj.upadhyay@kernel.org>
kernel/rcu/tasks.h

index 72d564c84499ae254d4c46621a3ec4f5048df0e3..9fb8bb0afff741043a219386f94a45e7db4db979 100644 (file)
@@ -357,6 +357,7 @@ static void call_rcu_tasks_generic(struct rcu_head *rhp, rcu_callback_t func,
        rcu_read_lock();
        ideal_cpu = smp_processor_id() >> READ_ONCE(rtp->percpu_enqueue_shift);
        chosen_cpu = cpumask_next(ideal_cpu - 1, cpu_possible_mask);
+       WARN_ON_ONCE(chosen_cpu >= rcu_task_cpu_ids);
        rtpcp = per_cpu_ptr(rtp->rtpcpu, chosen_cpu);
        if (!raw_spin_trylock_rcu_node(rtpcp)) { // irqs already disabled.
                raw_spin_lock_rcu_node(rtpcp); // irqs already disabled.