[hrtimer] Remove listhead from hrtimer struct

The list_head in the hrtimer structure was introduced for easy access
to the first timer with the further extensions of real high resolution
timers in mind, but it turned out in the course of development that
it is not necessary for the standard use case. Remove the list head
and access the first expiry timer by a datafield in the timer base.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

+16 -17
+2 -5
include/linux/hrtimer.h
··· 49 * struct hrtimer - the basic hrtimer structure 50 * 51 * @node: red black tree node for time ordered insertion 52 - * @list: list head for easier access to the time ordered list, 53 - * without walking the red black tree. 54 * @expires: the absolute expiry time in the hrtimers internal 55 * representation. The time is related to the clock on 56 * which the timer is based. ··· 61 */ 62 struct hrtimer { 63 struct rb_node node; 64 - struct list_head list; 65 ktime_t expires; 66 enum hrtimer_state state; 67 int (*function)(void *); ··· 75 * to a base on another cpu. 76 * @lock: lock protecting the base and associated timers 77 * @active: red black tree root node for the active timers 78 - * @pending: list of pending timers for simple time ordered access 79 * @resolution: the resolution of the clock, in nanoseconds 80 * @get_time: function to retrieve the current time of the clock 81 * @curr_timer: the timer which is executing a callback right now ··· 84 clockid_t index; 85 spinlock_t lock; 86 struct rb_root active; 87 - struct list_head pending; 88 unsigned long resolution; 89 ktime_t (*get_time)(void); 90 struct hrtimer *curr_timer;
··· 49 * struct hrtimer - the basic hrtimer structure 50 * 51 * @node: red black tree node for time ordered insertion 52 * @expires: the absolute expiry time in the hrtimers internal 53 * representation. The time is related to the clock on 54 * which the timer is based. ··· 63 */ 64 struct hrtimer { 65 struct rb_node node; 66 ktime_t expires; 67 enum hrtimer_state state; 68 int (*function)(void *); ··· 78 * to a base on another cpu. 79 * @lock: lock protecting the base and associated timers 80 * @active: red black tree root node for the active timers 81 + * @first: pointer to the timer node which expires first 82 * @resolution: the resolution of the clock, in nanoseconds 83 * @get_time: function to retrieve the current time of the clock 84 * @curr_timer: the timer which is executing a callback right now ··· 87 clockid_t index; 88 spinlock_t lock; 89 struct rb_root active; 90 + struct rb_node *first; 91 unsigned long resolution; 92 ktime_t (*get_time)(void); 93 struct hrtimer *curr_timer;
+14 -12
kernel/hrtimer.c
··· 314 static void enqueue_hrtimer(struct hrtimer *timer, struct hrtimer_base *base) 315 { 316 struct rb_node **link = &base->active.rb_node; 317 - struct list_head *prev = &base->pending; 318 struct rb_node *parent = NULL; 319 struct hrtimer *entry; 320 ··· 329 */ 330 if (timer->expires.tv64 < entry->expires.tv64) 331 link = &(*link)->rb_left; 332 - else { 333 link = &(*link)->rb_right; 334 - prev = &entry->list; 335 - } 336 } 337 338 /* 339 - * Insert the timer to the rbtree and to the sorted list: 340 */ 341 rb_link_node(&timer->node, parent, link); 342 rb_insert_color(&timer->node, &base->active); 343 - list_add(&timer->list, prev); 344 345 timer->state = HRTIMER_PENDING; 346 - } 347 348 349 /* 350 * __remove_hrtimer - internal function to remove a timer ··· 355 static void __remove_hrtimer(struct hrtimer *timer, struct hrtimer_base *base) 356 { 357 /* 358 - * Remove the timer from the sorted list and from the rbtree: 359 */ 360 - list_del(&timer->list); 361 rb_erase(&timer->node, &base->active); 362 } 363 ··· 531 static inline void run_hrtimer_queue(struct hrtimer_base *base) 532 { 533 ktime_t now = base->get_time(); 534 535 spin_lock_irq(&base->lock); 536 537 - while (!list_empty(&base->pending)) { 538 struct hrtimer *timer; 539 int (*fn)(void *); 540 int restart; 541 void *data; 542 543 - timer = list_entry(base->pending.next, struct hrtimer, list); 544 if (now.tv64 <= timer->expires.tv64) 545 break; 546 ··· 735 736 for (i = 0; i < MAX_HRTIMER_BASES; i++) { 737 spin_lock_init(&base->lock); 738 - INIT_LIST_HEAD(&base->pending); 739 base++; 740 } 741 }
··· 314 static void enqueue_hrtimer(struct hrtimer *timer, struct hrtimer_base *base) 315 { 316 struct rb_node **link = &base->active.rb_node; 317 struct rb_node *parent = NULL; 318 struct hrtimer *entry; 319 ··· 330 */ 331 if (timer->expires.tv64 < entry->expires.tv64) 332 link = &(*link)->rb_left; 333 + else 334 link = &(*link)->rb_right; 335 } 336 337 /* 338 + * Insert the timer to the rbtree and check whether it 339 + * replaces the first pending timer 340 */ 341 rb_link_node(&timer->node, parent, link); 342 rb_insert_color(&timer->node, &base->active); 343 344 timer->state = HRTIMER_PENDING; 345 346 + if (!base->first || timer->expires.tv64 < 347 + rb_entry(base->first, struct hrtimer, node)->expires.tv64) 348 + base->first = &timer->node; 349 + } 350 351 /* 352 * __remove_hrtimer - internal function to remove a timer ··· 355 static void __remove_hrtimer(struct hrtimer *timer, struct hrtimer_base *base) 356 { 357 /* 358 + * Remove the timer from the rbtree and replace the 359 + * first entry pointer if necessary. 360 */ 361 + if (base->first == &timer->node) 362 + base->first = rb_next(&timer->node); 363 rb_erase(&timer->node, &base->active); 364 } 365 ··· 529 static inline void run_hrtimer_queue(struct hrtimer_base *base) 530 { 531 ktime_t now = base->get_time(); 532 + struct rb_node *node; 533 534 spin_lock_irq(&base->lock); 535 536 + while ((node = base->first)) { 537 struct hrtimer *timer; 538 int (*fn)(void *); 539 int restart; 540 void *data; 541 542 + timer = rb_entry(node, struct hrtimer, node); 543 if (now.tv64 <= timer->expires.tv64) 544 break; 545 ··· 732 733 for (i = 0; i < MAX_HRTIMER_BASES; i++) { 734 spin_lock_init(&base->lock); 735 base++; 736 } 737 }