Messages in this thread Patch in this message | | | From | Eric Dumazet <> | Date | Thu, 31 Mar 2022 14:45:25 -0700 | Subject | [BUG] rcu-tasks : should take care of sparse cpu masks |
| |
Hi Paul
It seems you assume per cpu ptr for arbitrary indexes (< nr_cpu_ids) are valid.
What do you think of the (untested) following patch ?
Thanks.
diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h index 99cf3a13954cfb17828fbbeeb884f11614a526a9..df3785be4022e903d9682dd403464aa9927aa5c2 100644 --- a/kernel/rcu/tasks.h +++ b/kernel/rcu/tasks.h @@ -273,13 +273,17 @@ static void call_rcu_tasks_generic(struct rcu_head *rhp, rcu_callback_t func, bool needadjust = false; bool needwake; struct rcu_tasks_percpu *rtpcp; + int ideal_cpu, chosen_cpu;
rhp->next = NULL; rhp->func = func; local_irq_save(flags); rcu_read_lock(); - rtpcp = per_cpu_ptr(rtp->rtpcpu, - smp_processor_id() >> READ_ONCE(rtp->percpu_enqueue_shift)); + + ideal_cpu = smp_processor_id() >> READ_ONCE(rtp->percpu_enqueue_shift); + chosen_cpu = cpumask_next(ideal_cpu - 1, cpu_online_mask); + + 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. j = jiffies;
| |