diff options
author | Ingo Molnar <mingo@elte.hu> | 2007-07-21 07:37:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-21 20:49:15 -0400 |
commit | 99bc2fcb283852931fb6bbef40f3df8316b59000 (patch) | |
tree | 98419250c75a78578cdf32391fa03b013d635056 | |
parent | 820de5c39ef7f6866d2c9e6c7d208bcd2a6e1942 (diff) |
hrtimer: speedup hrtimer_enqueue
Speedup hrtimer_enqueue by evaluating the rbtree insertion result.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: john stultz <johnstul@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | kernel/hrtimer.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index 065a89786628..eb1ddebd2c04 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c | |||
@@ -686,6 +686,7 @@ static void enqueue_hrtimer(struct hrtimer *timer, | |||
686 | struct rb_node **link = &base->active.rb_node; | 686 | struct rb_node **link = &base->active.rb_node; |
687 | struct rb_node *parent = NULL; | 687 | struct rb_node *parent = NULL; |
688 | struct hrtimer *entry; | 688 | struct hrtimer *entry; |
689 | int leftmost = 1; | ||
689 | 690 | ||
690 | /* | 691 | /* |
691 | * Find the right place in the rbtree: | 692 | * Find the right place in the rbtree: |
@@ -697,18 +698,19 @@ static void enqueue_hrtimer(struct hrtimer *timer, | |||
697 | * We dont care about collisions. Nodes with | 698 | * We dont care about collisions. Nodes with |
698 | * the same expiry time stay together. | 699 | * the same expiry time stay together. |
699 | */ | 700 | */ |
700 | if (timer->expires.tv64 < entry->expires.tv64) | 701 | if (timer->expires.tv64 < entry->expires.tv64) { |
701 | link = &(*link)->rb_left; | 702 | link = &(*link)->rb_left; |
702 | else | 703 | } else { |
703 | link = &(*link)->rb_right; | 704 | link = &(*link)->rb_right; |
705 | leftmost = 0; | ||
706 | } | ||
704 | } | 707 | } |
705 | 708 | ||
706 | /* | 709 | /* |
707 | * Insert the timer to the rbtree and check whether it | 710 | * Insert the timer to the rbtree and check whether it |
708 | * replaces the first pending timer | 711 | * replaces the first pending timer |
709 | */ | 712 | */ |
710 | if (!base->first || timer->expires.tv64 < | 713 | if (leftmost) { |
711 | rb_entry(base->first, struct hrtimer, node)->expires.tv64) { | ||
712 | /* | 714 | /* |
713 | * Reprogram the clock event device. When the timer is already | 715 | * Reprogram the clock event device. When the timer is already |
714 | * expired hrtimer_enqueue_reprogram has either called the | 716 | * expired hrtimer_enqueue_reprogram has either called the |