tick/broadcast: Serialize access to tick_next_period
authorThomas Gleixner <tglx@linutronix.de>
Tue, 17 Nov 2020 13:19:43 +0000 (14:19 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 19 Nov 2020 09:48:28 +0000 (10:48 +0100)
commitf73f64d5687192bc8eb7f3d9521ca6256b79f224
tree9697fa0581b26217f309095d33fe7cd2a82a0f9e
parent66981c37b3199d293c58f84cf2366e86a06e1a3d
tick/broadcast: Serialize access to tick_next_period

tick_broadcast_setup_oneshot() accesses tick_next_period twice without any
serialization. This is wrong in two aspects:

  - Reading it twice might make the broadcast data inconsistent if the
    variable is updated concurrently.

  - On 32bit systems the access might see an partial update

Protect it with jiffies_lock. That's safe as none of the callchains leading
up to this function can create a lock ordering violation:

timer interrupt
  run_local_timers()
    hrtimer_run_queues()
      hrtimer_switch_to_hres()
        tick_init_highres()
  tick_switch_to_oneshot()
    tick_broadcast_switch_to_oneshot()
or
     tick_check_oneshot_change()
       tick_nohz_switch_to_nohz()
         tick_switch_to_oneshot()
           tick_broadcast_switch_to_oneshot()

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20201117132006.061341507@linutronix.de
kernel/time/tick-broadcast.c