hc
2024-10-09 05e59e5fb0064c97a1c10921ecd549f2d4a58565
kernel/include/linux/timerqueue.h
....@@ -12,8 +12,7 @@
1212 };
1313
1414 struct timerqueue_head {
15
- struct rb_root head;
16
- struct timerqueue_node *next;
15
+ struct rb_root_cached rb_root;
1716 };
1817
1918
....@@ -29,13 +28,14 @@
2928 *
3029 * @head: head of timerqueue
3130 *
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.
3432 */
3533 static inline
3634 struct timerqueue_node *timerqueue_getnext(struct timerqueue_head *head)
3735 {
38
- return head->next;
36
+ struct rb_node *leftmost = rb_first_cached(&head->rb_root);
37
+
38
+ return rb_entry_safe(leftmost, struct timerqueue_node, node);
3939 }
4040
4141 static inline void timerqueue_init(struct timerqueue_node *node)
....@@ -43,9 +43,18 @@
4343 RB_CLEAR_NODE(&node->node);
4444 }
4545
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
+
4656 static inline void timerqueue_init_head(struct timerqueue_head *head)
4757 {
48
- head->head = RB_ROOT;
49
- head->next = NULL;
58
+ head->rb_root = RB_ROOT_CACHED;
5059 }
5160 #endif /* _LINUX_TIMERQUEUE_H */