History

hrtimer: speedup hrtimer_enqueue

Speedup hrtimer_enqueue by evaluating the rbtree insertion result.

Ingo Molnar committed 19 years ago

Commit 99bc2fc1 parent 820de5c1 file · +6 −4Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/hrtimer.c+6−4
@@ -686,6 +686,7 @@ static void enqueue_hrtimer(struct hrtimer *timer, · 685 unmodified lines
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, · 5 unmodified lines
697 * We dont care about collisions. Nodes with698 * 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 else703 } 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 it710 * Insert the timer to the rbtree and check whether it
708 * replaces the first pending timer711 * 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 already715 * Reprogram the clock event device. When the timer is already
714 * expired hrtimer_enqueue_reprogram has either called the716 * expired hrtimer_enqueue_reprogram has either called the