mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [BUG] rcu-tasks : should take care of sparse cpu masks
@ 2022-03-31 21:45 Eric Dumazet
  2022-03-31 22:42 ` Paul E. McKenney
  0 siblings, 1 reply; 22+ messages in thread
From: Eric Dumazet @ 2022-03-31 21:45 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: LKML

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;

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2022-04-12 17:13 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-31 21:45 [BUG] rcu-tasks : should take care of sparse cpu masks Eric Dumazet
2022-03-31 22:42 ` Paul E. McKenney
2022-03-31 22:54   ` Eric Dumazet
2022-03-31 22:57     ` Eric Dumazet
2022-03-31 23:13       ` Paul E. McKenney
2022-03-31 23:28         ` Eric Dumazet
2022-04-01  0:06           ` Paul E. McKenney
2022-04-01  4:39             ` Eric Dumazet
2022-04-01 13:01               ` Paul E. McKenney
2022-04-01 13:24                 ` Eric Dumazet
2022-04-01 15:20                   ` Paul E. McKenney
2022-04-01 15:28                     ` Paul E. McKenney
2022-04-01 15:48                       ` Paul E. McKenney
2022-04-04  5:45                         ` Neeraj Upadhyay
2022-04-05  0:04                           ` KP Singh
2022-04-05 20:38                             ` Martin KaFai Lau
2022-04-06 15:44                               ` KP Singh
2022-04-12  6:28                                 ` KP Singh
2022-04-12 17:13                                   ` Martin KaFai Lau
2022-03-31 23:10     ` Paul E. McKenney
2022-04-04 19:49     ` Paul E. McKenney
2022-04-04 22:37       ` Eric Dumazet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®