As HK_TYPE_TIMER cpumask is going to be changeable at run time, use
RCU to protect access to the cpumask.

Signed-off-by: Waiman Long <[email protected]>
---
 kernel/workqueue.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 08b1c786b463..2dab3872281a 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -2557,8 +2557,10 @@ static void __queue_delayed_work(int cpu, struct 
workqueue_struct *wq,
        if (housekeeping_enabled(HK_TYPE_TIMER)) {
                /* If the current cpu is a housekeeping cpu, use it. */
                cpu = smp_processor_id();
-               if (!housekeeping_test_cpu(cpu, HK_TYPE_TIMER))
-                       cpu = housekeeping_any_cpu(HK_TYPE_TIMER);
+               scoped_guard(rcu) {
+                       if (!housekeeping_test_cpu(cpu, HK_TYPE_TIMER))
+                               cpu = housekeeping_any_cpu(HK_TYPE_TIMER);
+               }
                add_timer_on(timer, cpu);
        } else {
                if (likely(cpu == WORK_CPU_UNBOUND))
-- 
2.53.0


Reply via email to