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

The access of HK_TYPE_TIMER cpumask within hrtimers_cpu_dying() is
protected as interrupt is disabled and all the other CPUs are stopped
when this function is invoked as part of the CPU tear down process.

Signed-off-by: Waiman Long <[email protected]>
---
 kernel/time/hrtimer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 000fb6ba7d74..85495400a193 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -242,8 +242,10 @@ static bool hrtimer_suitable_target(struct hrtimer *timer, 
struct hrtimer_clock_
 static inline struct hrtimer_cpu_base *get_target_base(struct hrtimer_cpu_base 
*base, bool pinned)
 {
        if (!hrtimer_base_is_online(base)) {
-               int cpu = cpumask_any_and(cpu_online_mask, 
housekeeping_cpumask(HK_TYPE_TIMER));
+               int cpu;
 
+               guard(rcu)();
+               cpu = cpumask_any_and(cpu_online_mask, 
housekeeping_cpumask(HK_TYPE_TIMER));
                return &per_cpu(hrtimer_bases, cpu);
        }
 
-- 
2.53.0


Reply via email to