diff options
author | Davidlohr Bueso <dave@stgolabs.net> | 2017-09-08 16:14:39 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-09-08 18:26:48 -0700 |
commit | 2aadf7fc7df9e70c99786ffb8452ccdd83d49e59 (patch) | |
tree | 91b8d6c896cb417ea43470e3413be515a7bcf22d /kernel/sched/cpufreq_schedutil.c | |
parent | cd9e61ed1eebbcd5dfad59475d41ec58d9b64b6a (diff) | |
download | linux-2aadf7fc7df9e70c99786ffb8452ccdd83d49e59.tar.gz linux-2aadf7fc7df9e70c99786ffb8452ccdd83d49e59.tar.bz2 linux-2aadf7fc7df9e70c99786ffb8452ccdd83d49e59.zip |
rbtree: optimize root-check during rebalancing loop
The only times the nil-parent (root node) condition is true is when the
node is the first in the tree, or after fixing rbtree rule #4 and the
case 1 rebalancing made the node the root. Such conditions do not apply
most of the time:
(i) The common case in an rbtree is to have more than a single node,
so this is only true for the first rb_insert().
(ii) While there is a chance only one first rotation is needed, cases
where the node's uncle is black (cases 2,3) are more common as we can
have the following scenarios during the rotation looping:
case1 only, case1+1, case2+3, case1+2+3, case3 only, etc.
This patch, therefore, adds an unlikely() optimization to this
conditional. When profiling with CONFIG_PROFILE_ANNOTATED_BRANCHES, a
kernel build shows that the incorrect rate is less than 15%, and for
workloads that involve insert mostly trees overtime tend to have less
than 2% incorrect rate.
Link: http://lkml.kernel.org/r/20170719014603.19029-3-dave@stgolabs.net
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/sched/cpufreq_schedutil.c')
0 files changed, 0 insertions, 0 deletions