Speedup hrtimer_enqueue by evaluating the rbtree insertion result.
Showing the changes to kernel/hrtimer.c (1 of 1 file). Show all
Unified · Split
| @@ -686,6 +686,7 @@ static void enqueue_hrtimer(struct hrtimer *timer, · 685 unmodified lines | ||
| 686 | 686 | struct rb_node **link = &base->active.rb_node; |
| 687 | 687 | struct rb_node *parent = NULL; |
| 688 | 688 | struct hrtimer *entry; |
| 689 | + int leftmost = 1; | |
| 689 | 690 | |
| 690 | 691 | /* |
| 691 | 692 | * Find the right place in the rbtree: |
| @@ -697,18 +698,19 @@ static void enqueue_hrtimer(struct hrtimer *timer, · 5 unmodified lines | ||
| 697 | 698 | * We dont care about collisions. Nodes with |
| 698 | 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 | 702 | link = &(*link)->rb_left; |
| 702 | − else | |
| 703 | + } else { | |
| 703 | 704 | link = &(*link)->rb_right; |
| 705 | + leftmost = 0; | |
| 706 | + } | |
| 704 | 707 | } |
| 705 | 708 | |
| 706 | 709 | /* |
| 707 | 710 | * Insert the timer to the rbtree and check whether it |
| 708 | 711 | * replaces the first pending timer |
| 709 | 712 | */ |
| 710 | − if (!base->first || timer->expires.tv64 < | |
| 711 | − rb_entry(base->first, struct hrtimer, node)->expires.tv64) { | |
| 713 | + if (leftmost) { | |
| 712 | 714 | /* |
| 713 | 715 | * Reprogram the clock event device. When the timer is already |
| 714 | 716 | * expired hrtimer_enqueue_reprogram has either called the |