| .. | .. |
|---|
| 12 | 12 | }; |
|---|
| 13 | 13 | |
|---|
| 14 | 14 | struct timerqueue_head { |
|---|
| 15 | | - struct rb_root head; |
|---|
| 16 | | - struct timerqueue_node *next; |
|---|
| 15 | + struct rb_root_cached rb_root; |
|---|
| 17 | 16 | }; |
|---|
| 18 | 17 | |
|---|
| 19 | 18 | |
|---|
| .. | .. |
|---|
| 29 | 28 | * |
|---|
| 30 | 29 | * @head: head of timerqueue |
|---|
| 31 | 30 | * |
|---|
| 32 | | - * Returns a pointer to the timer node that has the |
|---|
| 33 | | - * earliest expiration time. |
|---|
| 31 | + * Returns a pointer to the timer node that has the earliest expiration time. |
|---|
| 34 | 32 | */ |
|---|
| 35 | 33 | static inline |
|---|
| 36 | 34 | struct timerqueue_node *timerqueue_getnext(struct timerqueue_head *head) |
|---|
| 37 | 35 | { |
|---|
| 38 | | - return head->next; |
|---|
| 36 | + struct rb_node *leftmost = rb_first_cached(&head->rb_root); |
|---|
| 37 | + |
|---|
| 38 | + return rb_entry(leftmost, struct timerqueue_node, node); |
|---|
| 39 | 39 | } |
|---|
| 40 | 40 | |
|---|
| 41 | 41 | static inline void timerqueue_init(struct timerqueue_node *node) |
|---|
| .. | .. |
|---|
| 43 | 43 | RB_CLEAR_NODE(&node->node); |
|---|
| 44 | 44 | } |
|---|
| 45 | 45 | |
|---|
| 46 | +static inline bool timerqueue_node_queued(struct timerqueue_node *node) |
|---|
| 47 | +{ |
|---|
| 48 | + return !RB_EMPTY_NODE(&node->node); |
|---|
| 49 | +} |
|---|
| 50 | + |
|---|
| 51 | +static inline bool timerqueue_node_expires(struct timerqueue_node *node) |
|---|
| 52 | +{ |
|---|
| 53 | + return node->expires; |
|---|
| 54 | +} |
|---|
| 55 | + |
|---|
| 46 | 56 | static inline void timerqueue_init_head(struct timerqueue_head *head) |
|---|
| 47 | 57 | { |
|---|
| 48 | | - head->head = RB_ROOT; |
|---|
| 49 | | - head->next = NULL; |
|---|
| 58 | + head->rb_root = RB_ROOT_CACHED; |
|---|
| 50 | 59 | } |
|---|
| 51 | 60 | #endif /* _LINUX_TIMERQUEUE_H */ |
|---|