From: Roman Zippel Remove the state field and encode this information in the rb_node similiar to normal timer. Signed-off-by: Roman Zippel Acked-by: Ingo Molnar Acked-by: Thomas Gleixner Signed-off-by: Andrew Morton --- include/linux/hrtimer.h | 11 ++--------- kernel/hrtimer.c | 13 ++++--------- 2 files changed, 6 insertions(+), 18 deletions(-) diff -puN include/linux/hrtimer.h~hrtimer-remove-state-field include/linux/hrtimer.h --- devel/include/linux/hrtimer.h~hrtimer-remove-state-field 2006-03-12 03:37:18.000000000 -0800 +++ devel-akpm/include/linux/hrtimer.h 2006-03-12 03:37:18.000000000 -0800 @@ -34,13 +34,7 @@ enum hrtimer_restart { HRTIMER_RESTART, }; -/* - * Timer states: - */ -enum hrtimer_state { - HRTIMER_INACTIVE, /* Timer is inactive */ - HRTIMER_PENDING, /* Timer is pending */ -}; +#define HRTIMER_INACTIVE ((void *)1UL) struct hrtimer_base; @@ -61,7 +55,6 @@ struct hrtimer_base; struct hrtimer { struct rb_node node; ktime_t expires; - enum hrtimer_state state; int (*function)(void *); void *data; struct hrtimer_base *base; @@ -124,7 +117,7 @@ extern ktime_t hrtimer_get_next_event(vo static inline int hrtimer_active(const struct hrtimer *timer) { - return timer->state == HRTIMER_PENDING; + return timer->node.rb_parent != HRTIMER_INACTIVE; } /* Forward a hrtimer so it expires after now: */ diff -puN kernel/hrtimer.c~hrtimer-remove-state-field kernel/hrtimer.c --- devel/kernel/hrtimer.c~hrtimer-remove-state-field 2006-03-12 03:37:18.000000000 -0800 +++ devel-akpm/kernel/hrtimer.c 2006-03-12 03:37:18.000000000 -0800 @@ -374,8 +374,6 @@ static void enqueue_hrtimer(struct hrtim rb_link_node(&timer->node, parent, link); rb_insert_color(&timer->node, &base->active); - timer->state = HRTIMER_PENDING; - if (!base->first || timer->expires.tv64 < rb_entry(base->first, struct hrtimer, node)->expires.tv64) base->first = &timer->node; @@ -395,6 +393,7 @@ static void __remove_hrtimer(struct hrti if (base->first == &timer->node) base->first = rb_next(&timer->node); rb_erase(&timer->node, &base->active); + timer->node.rb_parent = HRTIMER_INACTIVE; } /* @@ -405,7 +404,6 @@ remove_hrtimer(struct hrtimer *timer, st { if (hrtimer_active(timer)) { __remove_hrtimer(timer, base); - timer->state = HRTIMER_INACTIVE; return 1; } return 0; @@ -579,6 +577,7 @@ void hrtimer_init(struct hrtimer *timer, clock_id = CLOCK_MONOTONIC; timer->base = &bases[clock_id]; + timer->node.rb_parent = HRTIMER_INACTIVE; } /** @@ -625,7 +624,6 @@ static inline void run_hrtimer_queue(str fn = timer->function; data = timer->data; set_curr_timer(base, timer); - timer->state = HRTIMER_INACTIVE; __remove_hrtimer(timer, base); spin_unlock_irq(&base->lock); @@ -633,11 +631,8 @@ static inline void run_hrtimer_queue(str spin_lock_irq(&base->lock); - /* Another CPU has added back the timer */ - if (timer->state != HRTIMER_INACTIVE) - continue; - - if (restart != HRTIMER_NORESTART) + if (restart != HRTIMER_NORESTART && + !hrtimer_active(timer)) enqueue_hrtimer(timer, base); } set_curr_timer(base, NULL); _