6 #include <linux/stddef.h>
7 #include <linux/prefetch.h>
8 #include <linux/kernel.h>
9 #include <asm/system.h>
13 * These are non-NULL pointers that will result in page faults
14 * under normal circumstances, used to verify that nobody uses
15 * non-initialized list entries.
17 #define LIST_POISON1 ((void *) 0x00100100)
18 #define LIST_POISON2 ((void *) 0x00200200)
21 * Simple doubly linked list implementation.
23 * Some of the internal functions ("__xxx") are useful when
24 * manipulating whole lists rather than single entries, as
25 * sometimes we already know the next/prev entries and we can
26 * generate better code by using them directly rather than
27 * using the generic single-entry routines.
31 struct list_head *next, *prev;
34 #define LIST_HEAD_INIT(name) { &(name), &(name) }
36 #define LIST_HEAD(name) \
37 struct list_head name = LIST_HEAD_INIT(name)
39 static inline void INIT_LIST_HEAD(struct list_head *list)
46 * Insert a new entry between two known consecutive entries.
48 * This is only for internal list manipulation where we know
49 * the prev/next entries already!
51 static inline void __list_add(struct list_head *new,
52 struct list_head *prev,
53 struct list_head *next)
55 if (next->prev != prev) {
56 printk("List corruption. next->prev should be %p, but was %p\n",
60 if (prev->next != next) {
61 printk("List corruption. prev->next should be %p, but was %p\n",
72 * list_add - add a new entry
73 * @new: new entry to be added
74 * @head: list head to add it after
76 * Insert a new entry after the specified head.
77 * This is good for implementing stacks.
79 static inline void list_add(struct list_head *new, struct list_head *head)
81 __list_add(new, head, head->next);
85 * list_add_tail - add a new entry
86 * @new: new entry to be added
87 * @head: list head to add it before
89 * Insert a new entry before the specified head.
90 * This is useful for implementing queues.
92 static inline void list_add_tail(struct list_head *new, struct list_head *head)
94 __list_add(new, head->prev, head);
98 * Insert a new entry between two known consecutive entries.
100 * This is only for internal list manipulation where we know
101 * the prev/next entries already!
103 static inline void __list_add_rcu(struct list_head * new,
104 struct list_head * prev, struct list_head * next)
114 * list_add_rcu - add a new entry to rcu-protected list
115 * @new: new entry to be added
116 * @head: list head to add it after
118 * Insert a new entry after the specified head.
119 * This is good for implementing stacks.
121 * The caller must take whatever precautions are necessary
122 * (such as holding appropriate locks) to avoid racing
123 * with another list-mutation primitive, such as list_add_rcu()
124 * or list_del_rcu(), running on this same list.
125 * However, it is perfectly legal to run concurrently with
126 * the _rcu list-traversal primitives, such as
127 * list_for_each_entry_rcu().
129 static inline void list_add_rcu(struct list_head *new, struct list_head *head)
131 __list_add_rcu(new, head, head->next);
135 * list_add_tail_rcu - add a new entry to rcu-protected list
136 * @new: new entry to be added
137 * @head: list head to add it before
139 * Insert a new entry before the specified head.
140 * This is useful for implementing queues.
142 * The caller must take whatever precautions are necessary
143 * (such as holding appropriate locks) to avoid racing
144 * with another list-mutation primitive, such as list_add_tail_rcu()
145 * or list_del_rcu(), running on this same list.
146 * However, it is perfectly legal to run concurrently with
147 * the _rcu list-traversal primitives, such as
148 * list_for_each_entry_rcu().
150 static inline void list_add_tail_rcu(struct list_head *new,
151 struct list_head *head)
153 __list_add_rcu(new, head->prev, head);
157 * Delete a list entry by making the prev/next entries
158 * point to each other.
160 * This is only for internal list manipulation where we know
161 * the prev/next entries already!
163 static inline void __list_del(struct list_head * prev, struct list_head * next)
170 * list_del - deletes entry from list.
171 * @entry: the element to delete from the list.
172 * Note: list_empty on entry does not return true after this, the entry is
173 * in an undefined state.
175 static inline void list_del(struct list_head *entry)
177 if (entry->prev->next != entry) {
178 printk("List corruption. prev->next should be %p, but was %p\n",
179 entry, entry->prev->next);
182 if (entry->next->prev != entry) {
183 printk("List corruption. next->prev should be %p, but was %p\n",
184 entry, entry->next->prev);
187 __list_del(entry->prev, entry->next);
188 entry->next = LIST_POISON1;
189 entry->prev = LIST_POISON2;
193 * list_del_rcu - deletes entry from list without re-initialization
194 * @entry: the element to delete from the list.
196 * Note: list_empty on entry does not return true after this,
197 * the entry is in an undefined state. It is useful for RCU based
198 * lockfree traversal.
200 * In particular, it means that we can not poison the forward
201 * pointers that may still be used for walking the list.
203 * The caller must take whatever precautions are necessary
204 * (such as holding appropriate locks) to avoid racing
205 * with another list-mutation primitive, such as list_del_rcu()
206 * or list_add_rcu(), running on this same list.
207 * However, it is perfectly legal to run concurrently with
208 * the _rcu list-traversal primitives, such as
209 * list_for_each_entry_rcu().
211 * Note that the caller is not permitted to immediately free
212 * the newly deleted entry. Instead, either synchronize_rcu()
213 * or call_rcu() must be used to defer freeing until an RCU
214 * grace period has elapsed.
216 static inline void list_del_rcu(struct list_head *entry)
218 __list_del(entry->prev, entry->next);
219 entry->prev = LIST_POISON2;
223 * list_replace_rcu - replace old entry by new one
224 * @old : the element to be replaced
225 * @new : the new element to insert
227 * The old entry will be replaced with the new entry atomically.
229 static inline void list_replace_rcu(struct list_head *old,
230 struct list_head *new)
232 new->next = old->next;
233 new->prev = old->prev;
235 new->next->prev = new;
236 new->prev->next = new;
237 old->prev = LIST_POISON2;
241 * list_del_init - deletes entry from list and reinitialize it.
242 * @entry: the element to delete from the list.
244 static inline void list_del_init(struct list_head *entry)
246 __list_del(entry->prev, entry->next);
247 INIT_LIST_HEAD(entry);
251 * list_move - delete from one list and add as another's head
252 * @list: the entry to move
253 * @head: the head that will precede our entry
255 static inline void list_move(struct list_head *list, struct list_head *head)
257 __list_del(list->prev, list->next);
258 list_add(list, head);
262 * list_move_tail - delete from one list and add as another's tail
263 * @list: the entry to move
264 * @head: the head that will follow our entry
266 static inline void list_move_tail(struct list_head *list,
267 struct list_head *head)
269 __list_del(list->prev, list->next);
270 list_add_tail(list, head);
274 * list_empty - tests whether a list is empty
275 * @head: the list to test.
277 static inline int list_empty(const struct list_head *head)
279 return head->next == head;
283 * list_empty_careful - tests whether a list is
284 * empty _and_ checks that no other CPU might be
285 * in the process of still modifying either member
287 * NOTE: using list_empty_careful() without synchronization
288 * can only be safe if the only activity that can happen
289 * to the list entry is list_del_init(). Eg. it cannot be used
290 * if another CPU could re-list_add() it.
292 * @head: the list to test.
294 static inline int list_empty_careful(const struct list_head *head)
296 struct list_head *next = head->next;
297 return (next == head) && (next == head->prev);
300 static inline void __list_splice(struct list_head *list,
301 struct list_head *head)
303 struct list_head *first = list->next;
304 struct list_head *last = list->prev;
305 struct list_head *at = head->next;
315 * list_splice - join two lists
316 * @list: the new list to add.
317 * @head: the place to add it in the first list.
319 static inline void list_splice(struct list_head *list, struct list_head *head)
321 if (!list_empty(list))
322 __list_splice(list, head);
326 * list_splice_init - join two lists and reinitialise the emptied list.
327 * @list: the new list to add.
328 * @head: the place to add it in the first list.
330 * The list at @list is reinitialised
332 static inline void list_splice_init(struct list_head *list,
333 struct list_head *head)
335 if (!list_empty(list)) {
336 __list_splice(list, head);
337 INIT_LIST_HEAD(list);
342 * list_entry - get the struct for this entry
343 * @ptr: the &struct list_head pointer.
344 * @type: the type of the struct this is embedded in.
345 * @member: the name of the list_struct within the struct.
347 #define list_entry(ptr, type, member) \
348 container_of(ptr, type, member)
351 * list_for_each - iterate over a list
352 * @pos: the &struct list_head to use as a loop counter.
353 * @head: the head for your list.
355 #define list_for_each(pos, head) \
356 for (pos = (head)->next; prefetch(pos->next), pos != (head); \
360 * __list_for_each - iterate over a list
361 * @pos: the &struct list_head to use as a loop counter.
362 * @head: the head for your list.
364 * This variant differs from list_for_each() in that it's the
365 * simplest possible list iteration code, no prefetching is done.
366 * Use this for code that knows the list to be very short (empty
367 * or 1 entry) most of the time.
369 #define __list_for_each(pos, head) \
370 for (pos = (head)->next; pos != (head); pos = pos->next)
373 * list_for_each_prev - iterate over a list backwards
374 * @pos: the &struct list_head to use as a loop counter.
375 * @head: the head for your list.
377 #define list_for_each_prev(pos, head) \
378 for (pos = (head)->prev; prefetch(pos->prev), pos != (head); \
382 * list_for_each_safe - iterate over a list safe against removal of list entry
383 * @pos: the &struct list_head to use as a loop counter.
384 * @n: another &struct list_head to use as temporary storage
385 * @head: the head for your list.
387 #define list_for_each_safe(pos, n, head) \
388 for (pos = (head)->next, n = pos->next; pos != (head); \
389 pos = n, n = pos->next)
392 * list_for_each_entry - iterate over list of given type
393 * @pos: the type * to use as a loop counter.
394 * @head: the head for your list.
395 * @member: the name of the list_struct within the struct.
397 #define list_for_each_entry(pos, head, member) \
398 for (pos = list_entry((head)->next, typeof(*pos), member); \
399 prefetch(pos->member.next), &pos->member != (head); \
400 pos = list_entry(pos->member.next, typeof(*pos), member))
403 * list_for_each_entry_reverse - iterate backwards over list of given type.
404 * @pos: the type * to use as a loop counter.
405 * @head: the head for your list.
406 * @member: the name of the list_struct within the struct.
408 #define list_for_each_entry_reverse(pos, head, member) \
409 for (pos = list_entry((head)->prev, typeof(*pos), member); \
410 prefetch(pos->member.prev), &pos->member != (head); \
411 pos = list_entry(pos->member.prev, typeof(*pos), member))
414 * list_prepare_entry - prepare a pos entry for use as a start point in
415 * list_for_each_entry_continue
416 * @pos: the type * to use as a start point
417 * @head: the head of the list
418 * @member: the name of the list_struct within the struct.
420 #define list_prepare_entry(pos, head, member) \
421 ((pos) ? : list_entry(head, typeof(*pos), member))
424 * list_for_each_entry_continue - iterate over list of given type
425 * continuing after existing point
426 * @pos: the type * to use as a loop counter.
427 * @head: the head for your list.
428 * @member: the name of the list_struct within the struct.
430 #define list_for_each_entry_continue(pos, head, member) \
431 for (pos = list_entry(pos->member.next, typeof(*pos), member); \
432 prefetch(pos->member.next), &pos->member != (head); \
433 pos = list_entry(pos->member.next, typeof(*pos), member))
436 * list_for_each_entry_from - iterate over list of given type
437 * continuing from existing point
438 * @pos: the type * to use as a loop counter.
439 * @head: the head for your list.
440 * @member: the name of the list_struct within the struct.
442 #define list_for_each_entry_from(pos, head, member) \
443 for (; prefetch(pos->member.next), &pos->member != (head); \
444 pos = list_entry(pos->member.next, typeof(*pos), member))
447 * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
448 * @pos: the type * to use as a loop counter.
449 * @n: another type * to use as temporary storage
450 * @head: the head for your list.
451 * @member: the name of the list_struct within the struct.
453 #define list_for_each_entry_safe(pos, n, head, member) \
454 for (pos = list_entry((head)->next, typeof(*pos), member), \
455 n = list_entry(pos->member.next, typeof(*pos), member); \
456 &pos->member != (head); \
457 pos = n, n = list_entry(n->member.next, typeof(*n), member))
460 * list_for_each_entry_safe_continue - iterate over list of given type
461 * continuing after existing point safe against removal of list entry
462 * @pos: the type * to use as a loop counter.
463 * @n: another type * to use as temporary storage
464 * @head: the head for your list.
465 * @member: the name of the list_struct within the struct.
467 #define list_for_each_entry_safe_continue(pos, n, head, member) \
468 for (pos = list_entry(pos->member.next, typeof(*pos), member), \
469 n = list_entry(pos->member.next, typeof(*pos), member); \
470 &pos->member != (head); \
471 pos = n, n = list_entry(n->member.next, typeof(*n), member))
474 * list_for_each_entry_safe_from - iterate over list of given type
475 * from existing point safe against removal of list entry
476 * @pos: the type * to use as a loop counter.
477 * @n: another type * to use as temporary storage
478 * @head: the head for your list.
479 * @member: the name of the list_struct within the struct.
481 #define list_for_each_entry_safe_from(pos, n, head, member) \
482 for (n = list_entry(pos->member.next, typeof(*pos), member); \
483 &pos->member != (head); \
484 pos = n, n = list_entry(n->member.next, typeof(*n), member))
487 * list_for_each_entry_safe_reverse - iterate backwards over list of given type safe against
488 * removal of list entry
489 * @pos: the type * to use as a loop counter.
490 * @n: another type * to use as temporary storage
491 * @head: the head for your list.
492 * @member: the name of the list_struct within the struct.
494 #define list_for_each_entry_safe_reverse(pos, n, head, member) \
495 for (pos = list_entry((head)->prev, typeof(*pos), member), \
496 n = list_entry(pos->member.prev, typeof(*pos), member); \
497 &pos->member != (head); \
498 pos = n, n = list_entry(n->member.prev, typeof(*n), member))
501 * list_for_each_rcu - iterate over an rcu-protected list
502 * @pos: the &struct list_head to use as a loop counter.
503 * @head: the head for your list.
505 * This list-traversal primitive may safely run concurrently with
506 * the _rcu list-mutation primitives such as list_add_rcu()
507 * as long as the traversal is guarded by rcu_read_lock().
509 #define list_for_each_rcu(pos, head) \
510 for (pos = (head)->next; \
511 prefetch(rcu_dereference(pos)->next), pos != (head); \
514 #define __list_for_each_rcu(pos, head) \
515 for (pos = (head)->next; \
516 rcu_dereference(pos) != (head); \
520 * list_for_each_safe_rcu - iterate over an rcu-protected list safe
521 * against removal of list entry
522 * @pos: the &struct list_head to use as a loop counter.
523 * @n: another &struct list_head to use as temporary storage
524 * @head: the head for your list.
526 * This list-traversal primitive may safely run concurrently with
527 * the _rcu list-mutation primitives such as list_add_rcu()
528 * as long as the traversal is guarded by rcu_read_lock().
530 #define list_for_each_safe_rcu(pos, n, head) \
531 for (pos = (head)->next; \
532 n = rcu_dereference(pos)->next, pos != (head); \
536 * list_for_each_entry_rcu - iterate over rcu list of given type
537 * @pos: the type * to use as a loop counter.
538 * @head: the head for your list.
539 * @member: the name of the list_struct within the struct.
541 * This list-traversal primitive may safely run concurrently with
542 * the _rcu list-mutation primitives such as list_add_rcu()
543 * as long as the traversal is guarded by rcu_read_lock().
545 #define list_for_each_entry_rcu(pos, head, member) \
546 for (pos = list_entry((head)->next, typeof(*pos), member); \
547 prefetch(rcu_dereference(pos)->member.next), \
548 &pos->member != (head); \
549 pos = list_entry(pos->member.next, typeof(*pos), member))
553 * list_for_each_continue_rcu - iterate over an rcu-protected list
554 * continuing after existing point.
555 * @pos: the &struct list_head to use as a loop counter.
556 * @head: the head for your list.
558 * This list-traversal primitive may safely run concurrently with
559 * the _rcu list-mutation primitives such as list_add_rcu()
560 * as long as the traversal is guarded by rcu_read_lock().
562 #define list_for_each_continue_rcu(pos, head) \
563 for ((pos) = (pos)->next; \
564 prefetch(rcu_dereference((pos))->next), (pos) != (head); \
568 * Double linked lists with a single pointer list head.
569 * Mostly useful for hash tables where the two pointer list head is
571 * You lose the ability to access the tail in O(1).
575 struct hlist_node *first;
579 struct hlist_node *next, **pprev;
582 #define HLIST_HEAD_INIT { .first = NULL }
583 #define HLIST_HEAD(name) struct hlist_head name = { .first = NULL }
584 #define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
585 static inline void INIT_HLIST_NODE(struct hlist_node *h)
591 static inline int hlist_unhashed(const struct hlist_node *h)
596 static inline int hlist_empty(const struct hlist_head *h)
601 static inline void __hlist_del(struct hlist_node *n)
603 struct hlist_node *next = n->next;
604 struct hlist_node **pprev = n->pprev;
610 static inline void hlist_del(struct hlist_node *n)
613 n->next = LIST_POISON1;
614 n->pprev = LIST_POISON2;
618 * hlist_del_rcu - deletes entry from hash list without re-initialization
619 * @n: the element to delete from the hash list.
621 * Note: list_unhashed() on entry does not return true after this,
622 * the entry is in an undefined state. It is useful for RCU based
623 * lockfree traversal.
625 * In particular, it means that we can not poison the forward
626 * pointers that may still be used for walking the hash list.
628 * The caller must take whatever precautions are necessary
629 * (such as holding appropriate locks) to avoid racing
630 * with another list-mutation primitive, such as hlist_add_head_rcu()
631 * or hlist_del_rcu(), running on this same list.
632 * However, it is perfectly legal to run concurrently with
633 * the _rcu list-traversal primitives, such as
634 * hlist_for_each_entry().
636 static inline void hlist_del_rcu(struct hlist_node *n)
639 n->pprev = LIST_POISON2;
642 static inline void hlist_del_init(struct hlist_node *n)
644 if (!hlist_unhashed(n)) {
651 * hlist_replace_rcu - replace old entry by new one
652 * @old : the element to be replaced
653 * @new : the new element to insert
655 * The old entry will be replaced with the new entry atomically.
657 static inline void hlist_replace_rcu(struct hlist_node *old,
658 struct hlist_node *new)
660 struct hlist_node *next = old->next;
663 new->pprev = old->pprev;
666 new->next->pprev = &new->next;
668 old->pprev = LIST_POISON2;
671 static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
673 struct hlist_node *first = h->first;
676 first->pprev = &n->next;
678 n->pprev = &h->first;
683 * hlist_add_head_rcu - adds the specified element to the specified hlist,
684 * while permitting racing traversals.
685 * @n: the element to add to the hash list.
686 * @h: the list to add to.
688 * The caller must take whatever precautions are necessary
689 * (such as holding appropriate locks) to avoid racing
690 * with another list-mutation primitive, such as hlist_add_head_rcu()
691 * or hlist_del_rcu(), running on this same list.
692 * However, it is perfectly legal to run concurrently with
693 * the _rcu list-traversal primitives, such as
694 * hlist_for_each_entry_rcu(), used to prevent memory-consistency
695 * problems on Alpha CPUs. Regardless of the type of CPU, the
696 * list-traversal primitive must be guarded by rcu_read_lock().
698 static inline void hlist_add_head_rcu(struct hlist_node *n,
699 struct hlist_head *h)
701 struct hlist_node *first = h->first;
703 n->pprev = &h->first;
706 first->pprev = &n->next;
710 /* next must be != NULL */
711 static inline void hlist_add_before(struct hlist_node *n,
712 struct hlist_node *next)
714 n->pprev = next->pprev;
716 next->pprev = &n->next;
720 static inline void hlist_add_after(struct hlist_node *n,
721 struct hlist_node *next)
723 next->next = n->next;
725 next->pprev = &n->next;
728 next->next->pprev = &next->next;
732 * hlist_add_before_rcu - adds the specified element to the specified hlist
733 * before the specified node while permitting racing traversals.
734 * @n: the new element to add to the hash list.
735 * @next: the existing element to add the new element before.
737 * The caller must take whatever precautions are necessary
738 * (such as holding appropriate locks) to avoid racing
739 * with another list-mutation primitive, such as hlist_add_head_rcu()
740 * or hlist_del_rcu(), running on this same list.
741 * However, it is perfectly legal to run concurrently with
742 * the _rcu list-traversal primitives, such as
743 * hlist_for_each_entry_rcu(), used to prevent memory-consistency
744 * problems on Alpha CPUs.
746 static inline void hlist_add_before_rcu(struct hlist_node *n,
747 struct hlist_node *next)
749 n->pprev = next->pprev;
752 next->pprev = &n->next;
757 * hlist_add_after_rcu - adds the specified element to the specified hlist
758 * after the specified node while permitting racing traversals.
759 * @prev: the existing element to add the new element after.
760 * @n: the new element to add to the hash list.
762 * The caller must take whatever precautions are necessary
763 * (such as holding appropriate locks) to avoid racing
764 * with another list-mutation primitive, such as hlist_add_head_rcu()
765 * or hlist_del_rcu(), running on this same list.
766 * However, it is perfectly legal to run concurrently with
767 * the _rcu list-traversal primitives, such as
768 * hlist_for_each_entry_rcu(), used to prevent memory-consistency
769 * problems on Alpha CPUs.
771 static inline void hlist_add_after_rcu(struct hlist_node *prev,
772 struct hlist_node *n)
774 n->next = prev->next;
775 n->pprev = &prev->next;
779 n->next->pprev = &n->next;
782 #define hlist_entry(ptr, type, member) container_of(ptr,type,member)
784 #define hlist_for_each(pos, head) \
785 for (pos = (head)->first; pos && ({ prefetch(pos->next); 1; }); \
788 #define hlist_for_each_safe(pos, n, head) \
789 for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
793 * hlist_for_each_entry - iterate over list of given type
794 * @tpos: the type * to use as a loop counter.
795 * @pos: the &struct hlist_node to use as a loop counter.
796 * @head: the head for your list.
797 * @member: the name of the hlist_node within the struct.
799 #define hlist_for_each_entry(tpos, pos, head, member) \
800 for (pos = (head)->first; \
801 pos && ({ prefetch(pos->next); 1;}) && \
802 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
806 * hlist_for_each_entry_continue - iterate over a hlist continuing after existing point
807 * @tpos: the type * to use as a loop counter.
808 * @pos: the &struct hlist_node to use as a loop counter.
809 * @member: the name of the hlist_node within the struct.
811 #define hlist_for_each_entry_continue(tpos, pos, member) \
812 for (pos = (pos)->next; \
813 pos && ({ prefetch(pos->next); 1;}) && \
814 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
818 * hlist_for_each_entry_from - iterate over a hlist continuing from existing point
819 * @tpos: the type * to use as a loop counter.
820 * @pos: the &struct hlist_node to use as a loop counter.
821 * @member: the name of the hlist_node within the struct.
823 #define hlist_for_each_entry_from(tpos, pos, member) \
824 for (; pos && ({ prefetch(pos->next); 1;}) && \
825 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
829 * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
830 * @tpos: the type * to use as a loop counter.
831 * @pos: the &struct hlist_node to use as a loop counter.
832 * @n: another &struct hlist_node to use as temporary storage
833 * @head: the head for your list.
834 * @member: the name of the hlist_node within the struct.
836 #define hlist_for_each_entry_safe(tpos, pos, n, head, member) \
837 for (pos = (head)->first; \
838 pos && ({ n = pos->next; 1; }) && \
839 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
843 * hlist_for_each_entry_rcu - iterate over rcu list of given type
844 * @tpos: the type * to use as a loop counter.
845 * @pos: the &struct hlist_node to use as a loop counter.
846 * @head: the head for your list.
847 * @member: the name of the hlist_node within the struct.
849 * This list-traversal primitive may safely run concurrently with
850 * the _rcu list-mutation primitives such as hlist_add_head_rcu()
851 * as long as the traversal is guarded by rcu_read_lock().
853 #define hlist_for_each_entry_rcu(tpos, pos, head, member) \
854 for (pos = (head)->first; \
855 rcu_dereference(pos) && ({ prefetch(pos->next); 1;}) && \
856 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
860 #warning "don't include kernel headers in userspace"
861 #endif /* __KERNEL__ */