]> git.itanic.dy.fi Git - linux-stable/commit
lib/timerqueue: Rely on rbtree semantics for next timer
authorDavidlohr Bueso <dave@stgolabs.net>
Wed, 24 Jul 2019 15:23:23 +0000 (08:23 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 9 Oct 2021 12:09:46 +0000 (14:09 +0200)
commit0135fcb86a0bc9e4484f7e1228cadcc343c5edef
tree9b5d27bf3d8395ada562a613754e53eed7edfe1b
parentb1aa3a135c7be2b41134f938fc9769273246ad25
lib/timerqueue: Rely on rbtree semantics for next timer

commit 511885d7061eda3eb1faf3f57dcc936ff75863f1 upstream.

Simplify the timerqueue code by using cached rbtrees and rely on the tree
leftmost node semantics to get the timer with earliest expiration time.
This is a drop in conversion, and therefore semantics remain untouched.

The runtime overhead of cached rbtrees is be pretty much the same as the
current head->next method, noting that when removing the leftmost node,
a common operation for the timerqueue, the rb_next(leftmost) is O(1) as
well, so the next timer will either be the right node or its parent.
Therefore no extra pointer chasing. Finally, the size of the struct
timerqueue_head remains the same.

Passes several hours of rcutorture.

Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20190724152323.bojciei3muvfxalm@linux-r8p5
Reference: CVE-2021-20317
Signed-off-by: Nobuhiro Iwamatsu (CIP) <nobuhiro1.iwamatsu@toshiba.co.jp>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/timerqueue.h
lib/timerqueue.c