Commit b75f7a51 authored by Roman Zippel's avatar Roman Zippel Committed by Linus Torvalds

[PATCH] hrtimers: remove state field

Remove the state field and encode this information in the rb_node similiar to
normal timer.
Signed-off-by: default avatarRoman Zippel <zippel@linux-m68k.org>
Acked-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 432569bb
...@@ -34,13 +34,7 @@ enum hrtimer_restart { ...@@ -34,13 +34,7 @@ enum hrtimer_restart {
HRTIMER_RESTART, HRTIMER_RESTART,
}; };
/* #define HRTIMER_INACTIVE ((void *)1UL)
* Timer states:
*/
enum hrtimer_state {
HRTIMER_INACTIVE, /* Timer is inactive */
HRTIMER_PENDING, /* Timer is pending */
};
struct hrtimer_base; struct hrtimer_base;
...@@ -61,7 +55,6 @@ struct hrtimer_base; ...@@ -61,7 +55,6 @@ struct hrtimer_base;
struct hrtimer { struct hrtimer {
struct rb_node node; struct rb_node node;
ktime_t expires; ktime_t expires;
enum hrtimer_state state;
int (*function)(void *); int (*function)(void *);
void *data; void *data;
struct hrtimer_base *base; struct hrtimer_base *base;
...@@ -124,7 +117,7 @@ extern ktime_t hrtimer_get_next_event(void); ...@@ -124,7 +117,7 @@ extern ktime_t hrtimer_get_next_event(void);
static inline int hrtimer_active(const struct hrtimer *timer) 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: */ /* Forward a hrtimer so it expires after now: */
......
...@@ -374,8 +374,6 @@ static void enqueue_hrtimer(struct hrtimer *timer, struct hrtimer_base *base) ...@@ -374,8 +374,6 @@ static void enqueue_hrtimer(struct hrtimer *timer, struct hrtimer_base *base)
rb_link_node(&timer->node, parent, link); rb_link_node(&timer->node, parent, link);
rb_insert_color(&timer->node, &base->active); rb_insert_color(&timer->node, &base->active);
timer->state = HRTIMER_PENDING;
if (!base->first || timer->expires.tv64 < if (!base->first || timer->expires.tv64 <
rb_entry(base->first, struct hrtimer, node)->expires.tv64) rb_entry(base->first, struct hrtimer, node)->expires.tv64)
base->first = &timer->node; base->first = &timer->node;
...@@ -395,6 +393,7 @@ static void __remove_hrtimer(struct hrtimer *timer, struct hrtimer_base *base) ...@@ -395,6 +393,7 @@ static void __remove_hrtimer(struct hrtimer *timer, struct hrtimer_base *base)
if (base->first == &timer->node) if (base->first == &timer->node)
base->first = rb_next(&timer->node); base->first = rb_next(&timer->node);
rb_erase(&timer->node, &base->active); rb_erase(&timer->node, &base->active);
timer->node.rb_parent = HRTIMER_INACTIVE;
} }
/* /*
...@@ -405,7 +404,6 @@ remove_hrtimer(struct hrtimer *timer, struct hrtimer_base *base) ...@@ -405,7 +404,6 @@ remove_hrtimer(struct hrtimer *timer, struct hrtimer_base *base)
{ {
if (hrtimer_active(timer)) { if (hrtimer_active(timer)) {
__remove_hrtimer(timer, base); __remove_hrtimer(timer, base);
timer->state = HRTIMER_INACTIVE;
return 1; return 1;
} }
return 0; return 0;
...@@ -579,6 +577,7 @@ void hrtimer_init(struct hrtimer *timer, clockid_t clock_id, ...@@ -579,6 +577,7 @@ void hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
clock_id = CLOCK_MONOTONIC; clock_id = CLOCK_MONOTONIC;
timer->base = &bases[clock_id]; timer->base = &bases[clock_id];
timer->node.rb_parent = HRTIMER_INACTIVE;
} }
/** /**
...@@ -625,7 +624,6 @@ static inline void run_hrtimer_queue(struct hrtimer_base *base) ...@@ -625,7 +624,6 @@ static inline void run_hrtimer_queue(struct hrtimer_base *base)
fn = timer->function; fn = timer->function;
data = timer->data; data = timer->data;
set_curr_timer(base, timer); set_curr_timer(base, timer);
timer->state = HRTIMER_INACTIVE;
__remove_hrtimer(timer, base); __remove_hrtimer(timer, base);
spin_unlock_irq(&base->lock); spin_unlock_irq(&base->lock);
...@@ -633,13 +631,11 @@ static inline void run_hrtimer_queue(struct hrtimer_base *base) ...@@ -633,13 +631,11 @@ static inline void run_hrtimer_queue(struct hrtimer_base *base)
spin_lock_irq(&base->lock); spin_lock_irq(&base->lock);
/* Another CPU has added back the timer */ if (restart != HRTIMER_NORESTART) {
if (timer->state != HRTIMER_INACTIVE) BUG_ON(hrtimer_active(timer));
continue;
if (restart != HRTIMER_NORESTART)
enqueue_hrtimer(timer, base); enqueue_hrtimer(timer, base);
} }
}
set_curr_timer(base, NULL); set_curr_timer(base, NULL);
spin_unlock_irq(&base->lock); spin_unlock_irq(&base->lock);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment