]> git.baikalelectronics.ru Git - 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)
commit33dbac099c81504a803f3b605fb805f8dd4ef514
treeef634a7c192d03dd1f04b82f20ef58e78b55b3be
parent30de4039b1381faf0562bbfda4856f23930ed1ca
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: 0f6ef5c4e693 ("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