]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
timers: Lock base for same bucket optimization
authorThomas Gleixner <tglx@linutronix.de>
Mon, 24 Oct 2016 09:55:10 +0000 (11:55 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 25 Oct 2016 14:27:39 +0000 (16:27 +0200)
commit4da9152a4308dcbf611cde399c695c359fc9145f
treeef634a7c192d03dd1f04b82f20ef58e78b55b3be
parentb831275a3553c32091222ac619cfddd73a5553fb
timers: Lock base for same bucket optimization

Linus stumbled over the unlocked modification of the timer expiry value in
mod_timer() which is an optimization for timers which stay in the same
bucket - due to the bucket granularity - despite their expiry time getting
updated.

The optimization itself still makes sense even if we take the lock, because
in case that the bucket stays the same, we avoid the pointless
queue/enqueue dance.

Make the check and the modification of timer->expires protected by the base
lock and shuffle the remaining code around so we can keep the lock held
when we actually have to requeue the timer to a different bucket.

Fixes: f00c0afdfa62 ("timers: Implement optimization for same expiry time in mod_timer()")
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/alpine.DEB.2.20.1610241711220.4983@nanos
Cc: stable@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
kernel/time/timer.c