6 #include <linux/stddef.h>
7 #include <linux/prefetch.h>
8 #include <asm/system.h>
11 * These are non-NULL pointers that will result in page faults
12 * under normal circumstances, used to verify that nobody uses
13 * non-initialized list entries.
15 #define LIST_POISON1 ((void *) 0x00100100)
16 #define LIST_POISON2 ((void *) 0x00200200)
19 * Simple doubly linked list implementation.
21 * Some of the internal functions ("__xxx") are useful when
22 * manipulating whole lists rather than single entries, as
23 * sometimes we already know the next/prev entries and we can
24 * generate better code by using them directly rather than
25 * using the generic single-entry routines.
29 struct list_head *next, *prev;
32 #define LIST_HEAD_INIT(name) { &(name), &(name) }
34 #define LIST_HEAD(name) \
35 struct list_head name = LIST_HEAD_INIT(name)
37 static inline void INIT_LIST_HEAD(struct list_head *list)
44 * Insert a new entry between two known consecutive entries.
46 * This is only for internal list manipulation where we know
47 * the prev/next entries already!
49 static inline void __list_add(struct list_head *new,
50 struct list_head *prev,
51 struct list_head *next)
60 * list_add - add a new entry
61 * @new: new entry to be added
62 * @head: list head to add it after
64 * Insert a new entry after the specified head.
65 * This is good for implementing stacks.
67 static inline void list_add(struct list_head *new, struct list_head *head)
69 __list_add(new, head, head->next);
73 * list_add_tail - add a new entry
74 * @new: new entry to be added
75 * @head: list head to add it before
77 * Insert a new entry before the specified head.
78 * This is useful for implementing queues.
80 static inline void list_add_tail(struct list_head *new, struct list_head *head)
82 __list_add(new, head->prev, head);
86 * Insert a new entry between two known consecutive entries.
88 * This is only for internal list manipulation where we know
89 * the prev/next entries already!
91 static inline void __list_add_rcu(struct list_head * new,
92 struct list_head * prev, struct list_head * next)
102 * list_add_rcu - add a new entry to rcu-protected list
103 * @new: new entry to be added
104 * @head: list head to add it after
106 * Insert a new entry after the specified head.
107 * This is good for implementing stacks.
109 * The caller must take whatever precautions are necessary
110 * (such as holding appropriate locks) to avoid racing
111 * with another list-mutation primitive, such as list_add_rcu()
112 * or list_del_rcu(), running on this same list.
113 * However, it is perfectly legal to run concurrently with
114 * the _rcu list-traversal primitives, such as
115 * list_for_each_entry_rcu().
117 static inline void list_add_rcu(struct list_head *new, struct list_head *head)
119 __list_add_rcu(new, head, head->next);
123 * list_add_tail_rcu - add a new entry to rcu-protected list
124 * @new: new entry to be added
125 * @head: list head to add it before
127 * Insert a new entry before the specified head.
128 * This is useful for implementing queues.
130 * The caller must take whatever precautions are necessary
131 * (such as holding appropriate locks) to avoid racing
132 * with another list-mutation primitive, such as list_add_tail_rcu()
133 * or list_del_rcu(), running on this same list.
134 * However, it is perfectly legal to run concurrently with
135 * the _rcu list-traversal primitives, such as
136 * list_for_each_entry_rcu().
138 static inline void list_add_tail_rcu(struct list_head *new,
139 struct list_head *head)
141 __list_add_rcu(new, head->prev, head);
145 * Delete a list entry by making the prev/next entries
146 * point to each other.
148 * This is only for internal list manipulation where we know
149 * the prev/next entries already!
151 static inline void __list_del(struct list_head * prev, struct list_head * next)
158 * list_del - deletes entry from list.
159 * @entry: the element to delete from the list.
160 * Note: list_empty on entry does not return true after this, the entry is
161 * in an undefined state.
163 static inline void list_del(struct list_head *entry)
165 __list_del(entry->prev, entry->next);
166 entry->next = LIST_POISON1;
167 entry->prev = LIST_POISON2;
171 * list_del_rcu - deletes entry from list without re-initialization
172 * @entry: the element to delete from the list.
174 * Note: list_empty on entry does not return true after this,
175 * the entry is in an undefined state. It is useful for RCU based
176 * lockfree traversal.
178 * In particular, it means that we can not poison the forward
179 * pointers that may still be used for walking the list.
181 * The caller must take whatever precautions are necessary
182 * (such as holding appropriate locks) to avoid racing
183 * with another list-mutation primitive, such as list_del_rcu()
184 * or list_add_rcu(), running on this same list.
185 * However, it is perfectly legal to run concurrently with
186 * the _rcu list-traversal primitives, such as
187 * list_for_each_entry_rcu().
189 * Note that the caller is not permitted to immediately free
190 * the newly deleted entry. Instead, either synchronize_rcu()
191 * or call_rcu() must be used to defer freeing until an RCU
192 * grace period has elapsed.
194 static inline void list_del_rcu(struct list_head *entry)
196 __list_del(entry->prev, entry->next);
197 entry->prev = LIST_POISON2;
201 * list_replace - replace old entry by new one
202 * @old : the element to be replaced
203 * @new : the new element to insert
204 * Note: if 'old' was empty, it will be overwritten.
206 static inline void list_replace(struct list_head *old,
207 struct list_head *new)
209 new->next = old->next;
210 new->next->prev = new;
211 new->prev = old->prev;
212 new->prev->next = new;
215 static inline void list_replace_init(struct list_head *old,
216 struct list_head *new)
218 list_replace(old, new);
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.
228 * Note: 'old' should not be empty.
230 static inline void list_replace_rcu(struct list_head *old,
231 struct list_head *new)
233 new->next = old->next;
234 new->prev = old->prev;
236 new->next->prev = new;
237 new->prev->next = new;
238 old->prev = LIST_POISON2;
242 * list_del_init - deletes entry from list and reinitialize it.
243 * @entry: the element to delete from the list.
245 static inline void list_del_init(struct list_head *entry)
247 __list_del(entry->prev, entry->next);
248 INIT_LIST_HEAD(entry);
252 * list_move - delete from one list and add as another's head
253 * @list: the entry to move
254 * @head: the head that will precede our entry
256 static inline void list_move(struct list_head *list, struct list_head *head)
258 __list_del(list->prev, list->next);
259 list_add(list, head);
263 * list_move_tail - delete from one list and add as another's tail
264 * @list: the entry to move
265 * @head: the head that will follow our entry
267 static inline void list_move_tail(struct list_head *list,
268 struct list_head *head)
270 __list_del(list->prev, list->next);
271 list_add_tail(list, head);
275 * list_empty - tests whether a list is empty
276 * @head: the list to test.
278 static inline int list_empty(const struct list_head *head)
280 return head->next == head;
284 * list_empty_careful - tests whether a list is
285 * empty _and_ checks that no other CPU might be
286 * in the process of still modifying either member
288 * NOTE: using list_empty_careful() without synchronization
289 * can only be safe if the only activity that can happen
290 * to the list entry is list_del_init(). Eg. it cannot be used
291 * if another CPU could re-list_add() it.
293 * @head: the list to test.
295 static inline int list_empty_careful(const struct list_head *head)
297 struct list_head *next = head->next;
298 return (next == head) && (next == head->prev);
301 static inline void __list_splice(struct list_head *list,
302 struct list_head *head)
304 struct list_head *first = list->next;
305 struct list_head *last = list->prev;
306 struct list_head *at = head->next;
316 * list_splice - join two lists
317 * @list: the new list to add.
318 * @head: the place to add it in the first list.
320 static inline void list_splice(struct list_head *list, struct list_head *head)
322 if (!list_empty(list))
323 __list_splice(list, head);
327 * list_splice_init - join two lists and reinitialise the emptied list.
328 * @list: the new list to add.
329 * @head: the place to add it in the first list.
331 * The list at @list is reinitialised
333 static inline void list_splice_init(struct list_head *list,
334 struct list_head *head)
336 if (!list_empty(list)) {
337 __list_splice(list, head);
338 INIT_LIST_HEAD(list);
343 * list_entry - get the struct for this entry
344 * @ptr: the &struct list_head pointer.
345 * @type: the type of the struct this is embedded in.
346 * @member: the name of the list_struct within the struct.
348 #define list_entry(ptr, type, member) \
349 container_of(ptr, type, member)
352 * list_for_each - iterate over a list
353 * @pos: the &struct list_head to use as a loop counter.
354 * @head: the head for your list.
356 #define list_for_each(pos, head) \
357 for (pos = (head)->next; prefetch(pos->next), pos != (head); \
361 * __list_for_each - iterate over a list
362 * @pos: the &struct list_head to use as a loop counter.
363 * @head: the head for your list.
365 * This variant differs from list_for_each() in that it's the
366 * simplest possible list iteration code, no prefetching is done.
367 * Use this for code that knows the list to be very short (empty
368 * or 1 entry) most of the time.
370 #define __list_for_each(pos, head) \
371 for (pos = (head)->next; pos != (head); pos = pos->next)
374 * list_for_each_prev - iterate over a list backwards
375 * @pos: the &struct list_head to use as a loop counter.
376 * @head: the head for your list.
378 #define list_for_each_prev(pos, head) \
379 for (pos = (head)->prev; prefetch(pos->prev), pos != (head); \
383 * list_for_each_safe - iterate over a list safe against removal of list entry
384 * @pos: the &struct list_head to use as a loop counter.
385 * @n: another &struct list_head to use as temporary storage
386 * @head: the head for your list.
388 #define list_for_each_safe(pos, n, head) \
389 for (pos = (head)->next, n = pos->next; pos != (head); \
390 pos = n, n = pos->next)
393 * list_for_each_entry - iterate over list of given type
394 * @pos: the type * to use as a loop counter.
395 * @head: the head for your list.
396 * @member: the name of the list_struct within the struct.
398 #define list_for_each_entry(pos, head, member) \
399 for (pos = list_entry((head)->next, typeof(*pos), member); \
400 prefetch(pos->member.next), &pos->member != (head); \
401 pos = list_entry(pos->member.next, typeof(*pos), member))
404 * list_for_each_entry_reverse - iterate backwards over list of given type.
405 * @pos: the type * to use as a loop counter.
406 * @head: the head for your list.
407 * @member: the name of the list_struct within the struct.
409 #define list_for_each_entry_reverse(pos, head, member) \
410 for (pos = list_entry((head)->prev, typeof(*pos), member); \
411 prefetch(pos->member.prev), &pos->member != (head); \
412 pos = list_entry(pos->member.prev, typeof(*pos), member))
415 * list_prepare_entry - prepare a pos entry for use as a start point in
416 * list_for_each_entry_continue
417 * @pos: the type * to use as a start point
418 * @head: the head of the list
419 * @member: the name of the list_struct within the struct.
421 #define list_prepare_entry(pos, head, member) \
422 ((pos) ? : list_entry(head, typeof(*pos), member))
425 * list_for_each_entry_continue - iterate over list of given type
426 * continuing after existing point
427 * @pos: the type * to use as a loop counter.
428 * @head: the head for your list.
429 * @member: the name of the list_struct within the struct.
431 #define list_for_each_entry_continue(pos, head, member) \
432 for (pos = list_entry(pos->member.next, typeof(*pos), member); \
433 prefetch(pos->member.next), &pos->member != (head); \
434 pos = list_entry(pos->member.next, typeof(*pos), member))
437 * list_for_each_entry_from - iterate over list of given type
438 * continuing from existing point
439 * @pos: the type * to use as a loop counter.
440 * @head: the head for your list.
441 * @member: the name of the list_struct within the struct.
443 #define list_for_each_entry_from(pos, head, member) \
444 for (; prefetch(pos->member.next), &pos->member != (head); \
445 pos = list_entry(pos->member.next, typeof(*pos), member))
448 * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
449 * @pos: the type * to use as a loop counter.
450 * @n: another type * to use as temporary storage
451 * @head: the head for your list.
452 * @member: the name of the list_struct within the struct.
454 #define list_for_each_entry_safe(pos, n, head, member) \
455 for (pos = list_entry((head)->next, typeof(*pos), member), \
456 n = list_entry(pos->member.next, typeof(*pos), member); \
457 &pos->member != (head); \
458 pos = n, n = list_entry(n->member.next, typeof(*n), member))
461 * list_for_each_entry_safe_continue - iterate over list of given type
462 * continuing after existing point safe against removal of list entry
463 * @pos: the type * to use as a loop counter.
464 * @n: another type * to use as temporary storage
465 * @head: the head for your list.
466 * @member: the name of the list_struct within the struct.
468 #define list_for_each_entry_safe_continue(pos, n, head, member) \
469 for (pos = list_entry(pos->member.next, typeof(*pos), member), \
470 n = list_entry(pos->member.next, typeof(*pos), member); \
471 &pos->member != (head); \
472 pos = n, n = list_entry(n->member.next, typeof(*n), member))
475 * list_for_each_entry_safe_from - iterate over list of given type
476 * from existing point safe against removal of list entry
477 * @pos: the type * to use as a loop counter.
478 * @n: another type * to use as temporary storage
479 * @head: the head for your list.
480 * @member: the name of the list_struct within the struct.
482 #define list_for_each_entry_safe_from(pos, n, head, member) \
483 for (n = list_entry(pos->member.next, typeof(*pos), member); \
484 &pos->member != (head); \
485 pos = n, n = list_entry(n->member.next, typeof(*n), member))
488 * list_for_each_entry_safe_reverse - iterate backwards over list of given type safe against
489 * removal of list entry
490 * @pos: the type * to use as a loop counter.
491 * @n: another type * to use as temporary storage
492 * @head: the head for your list.
493 * @member: the name of the list_struct within the struct.
495 #define list_for_each_entry_safe_reverse(pos, n, head, member) \
496 for (pos = list_entry((head)->prev, typeof(*pos), member), \
497 n = list_entry(pos->member.prev, typeof(*pos), member); \
498 &pos->member != (head); \
499 pos = n, n = list_entry(n->member.prev, typeof(*n), member))
502 * list_for_each_rcu - iterate over an rcu-protected list
503 * @pos: the &struct list_head to use as a loop counter.
504 * @head: the head for your list.
506 * This list-traversal primitive may safely run concurrently with
507 * the _rcu list-mutation primitives such as list_add_rcu()
508 * as long as the traversal is guarded by rcu_read_lock().
510 #define list_for_each_rcu(pos, head) \
511 for (pos = (head)->next; \
512 prefetch(rcu_dereference(pos)->next), pos != (head); \
515 #define __list_for_each_rcu(pos, head) \
516 for (pos = (head)->next; \
517 rcu_dereference(pos) != (head); \
521 * list_for_each_safe_rcu - iterate over an rcu-protected list safe
522 * against removal of list entry
523 * @pos: the &struct list_head to use as a loop counter.
524 * @n: another &struct list_head to use as temporary storage
525 * @head: the head for your list.
527 * This list-traversal primitive may safely run concurrently with
528 * the _rcu list-mutation primitives such as list_add_rcu()
529 * as long as the traversal is guarded by rcu_read_lock().
531 #define list_for_each_safe_rcu(pos, n, head) \
532 for (pos = (head)->next; \
533 n = rcu_dereference(pos)->next, pos != (head); \
537 * list_for_each_entry_rcu - iterate over rcu list of given type
538 * @pos: the type * to use as a loop counter.
539 * @head: the head for your list.
540 * @member: the name of the list_struct within the struct.
542 * This list-traversal primitive may safely run concurrently with
543 * the _rcu list-mutation primitives such as list_add_rcu()
544 * as long as the traversal is guarded by rcu_read_lock().
546 #define list_for_each_entry_rcu(pos, head, member) \
547 for (pos = list_entry((head)->next, typeof(*pos), member); \
548 prefetch(rcu_dereference(pos)->member.next), \
549 &pos->member != (head); \
550 pos = list_entry(pos->member.next, typeof(*pos), member))
554 * list_for_each_continue_rcu - iterate over an rcu-protected list
555 * continuing after existing point.
556 * @pos: the &struct list_head to use as a loop counter.
557 * @head: the head for your list.
559 * This list-traversal primitive may safely run concurrently with
560 * the _rcu list-mutation primitives such as list_add_rcu()
561 * as long as the traversal is guarded by rcu_read_lock().
563 #define list_for_each_continue_rcu(pos, head) \
564 for ((pos) = (pos)->next; \
565 prefetch(rcu_dereference((pos))->next), (pos) != (head); \
569 * Double linked lists with a single pointer list head.
570 * Mostly useful for hash tables where the two pointer list head is
572 * You lose the ability to access the tail in O(1).
576 struct hlist_node *first;
580 struct hlist_node *next, **pprev;
583 #define HLIST_HEAD_INIT { .first = NULL }
584 #define HLIST_HEAD(name) struct hlist_head name = { .first = NULL }
585 #define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
586 static inline void INIT_HLIST_NODE(struct hlist_node *h)
592 static inline int hlist_unhashed(const struct hlist_node *h)
597 static inline int hlist_empty(const struct hlist_head *h)
602 static inline void __hlist_del(struct hlist_node *n)
604 struct hlist_node *next = n->next;
605 struct hlist_node **pprev = n->pprev;
611 static inline void hlist_del(struct hlist_node *n)
614 n->next = LIST_POISON1;
615 n->pprev = LIST_POISON2;
619 * hlist_del_rcu - deletes entry from hash list without re-initialization
620 * @n: the element to delete from the hash list.
622 * Note: list_unhashed() on entry does not return true after this,
623 * the entry is in an undefined state. It is useful for RCU based
624 * lockfree traversal.
626 * In particular, it means that we can not poison the forward
627 * pointers that may still be used for walking the hash list.
629 * The caller must take whatever precautions are necessary
630 * (such as holding appropriate locks) to avoid racing
631 * with another list-mutation primitive, such as hlist_add_head_rcu()
632 * or hlist_del_rcu(), running on this same list.
633 * However, it is perfectly legal to run concurrently with
634 * the _rcu list-traversal primitives, such as
635 * hlist_for_each_entry().
637 static inline void hlist_del_rcu(struct hlist_node *n)
640 n->pprev = LIST_POISON2;
643 static inline void hlist_del_init(struct hlist_node *n)
645 if (!hlist_unhashed(n)) {
652 * hlist_replace_rcu - replace old entry by new one
653 * @old : the element to be replaced
654 * @new : the new element to insert
656 * The old entry will be replaced with the new entry atomically.
658 static inline void hlist_replace_rcu(struct hlist_node *old,
659 struct hlist_node *new)
661 struct hlist_node *next = old->next;
664 new->pprev = old->pprev;
667 new->next->pprev = &new->next;
669 old->pprev = LIST_POISON2;
672 static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
674 struct hlist_node *first = h->first;
677 first->pprev = &n->next;
679 n->pprev = &h->first;
684 * hlist_add_head_rcu - adds the specified element to the specified hlist,
685 * while permitting racing traversals.
686 * @n: the element to add to the hash list.
687 * @h: the list to add to.
689 * The caller must take whatever precautions are necessary
690 * (such as holding appropriate locks) to avoid racing
691 * with another list-mutation primitive, such as hlist_add_head_rcu()
692 * or hlist_del_rcu(), running on this same list.
693 * However, it is perfectly legal to run concurrently with
694 * the _rcu list-traversal primitives, such as
695 * hlist_for_each_entry_rcu(), used to prevent memory-consistency
696 * problems on Alpha CPUs. Regardless of the type of CPU, the
697 * list-traversal primitive must be guarded by rcu_read_lock().
699 static inline void hlist_add_head_rcu(struct hlist_node *n,
700 struct hlist_head *h)
702 struct hlist_node *first = h->first;
704 n->pprev = &h->first;
707 first->pprev = &n->next;
711 /* next must be != NULL */
712 static inline void hlist_add_before(struct hlist_node *n,
713 struct hlist_node *next)
715 n->pprev = next->pprev;
717 next->pprev = &n->next;
721 static inline void hlist_add_after(struct hlist_node *n,
722 struct hlist_node *next)
724 next->next = n->next;
726 next->pprev = &n->next;
729 next->next->pprev = &next->next;
733 * hlist_add_before_rcu - adds the specified element to the specified hlist
734 * before the specified node while permitting racing traversals.
735 * @n: the new element to add to the hash list.
736 * @next: the existing element to add the new element before.
738 * The caller must take whatever precautions are necessary
739 * (such as holding appropriate locks) to avoid racing
740 * with another list-mutation primitive, such as hlist_add_head_rcu()
741 * or hlist_del_rcu(), running on this same list.
742 * However, it is perfectly legal to run concurrently with
743 * the _rcu list-traversal primitives, such as
744 * hlist_for_each_entry_rcu(), used to prevent memory-consistency
745 * problems on Alpha CPUs.
747 static inline void hlist_add_before_rcu(struct hlist_node *n,
748 struct hlist_node *next)
750 n->pprev = next->pprev;
753 next->pprev = &n->next;
758 * hlist_add_after_rcu - adds the specified element to the specified hlist
759 * after the specified node while permitting racing traversals.
760 * @prev: the existing element to add the new element after.
761 * @n: the new element to add to the hash list.
763 * The caller must take whatever precautions are necessary
764 * (such as holding appropriate locks) to avoid racing
765 * with another list-mutation primitive, such as hlist_add_head_rcu()
766 * or hlist_del_rcu(), running on this same list.
767 * However, it is perfectly legal to run concurrently with
768 * the _rcu list-traversal primitives, such as
769 * hlist_for_each_entry_rcu(), used to prevent memory-consistency
770 * problems on Alpha CPUs.
772 static inline void hlist_add_after_rcu(struct hlist_node *prev,
773 struct hlist_node *n)
775 n->next = prev->next;
776 n->pprev = &prev->next;
780 n->next->pprev = &n->next;
783 #define hlist_entry(ptr, type, member) container_of(ptr,type,member)
785 #define hlist_for_each(pos, head) \
786 for (pos = (head)->first; pos && ({ prefetch(pos->next); 1; }); \
789 #define hlist_for_each_safe(pos, n, head) \
790 for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
794 * hlist_for_each_entry - iterate over list of given type
795 * @tpos: the type * to use as a loop counter.
796 * @pos: the &struct hlist_node to use as a loop counter.
797 * @head: the head for your list.
798 * @member: the name of the hlist_node within the struct.
800 #define hlist_for_each_entry(tpos, pos, head, member) \
801 for (pos = (head)->first; \
802 pos && ({ prefetch(pos->next); 1;}) && \
803 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
807 * hlist_for_each_entry_continue - iterate over a hlist continuing after existing point
808 * @tpos: the type * to use as a loop counter.
809 * @pos: the &struct hlist_node to use as a loop counter.
810 * @member: the name of the hlist_node within the struct.
812 #define hlist_for_each_entry_continue(tpos, pos, member) \
813 for (pos = (pos)->next; \
814 pos && ({ prefetch(pos->next); 1;}) && \
815 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
819 * hlist_for_each_entry_from - iterate over a hlist continuing from existing point
820 * @tpos: the type * to use as a loop counter.
821 * @pos: the &struct hlist_node to use as a loop counter.
822 * @member: the name of the hlist_node within the struct.
824 #define hlist_for_each_entry_from(tpos, pos, member) \
825 for (; pos && ({ prefetch(pos->next); 1;}) && \
826 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
830 * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
831 * @tpos: the type * to use as a loop counter.
832 * @pos: the &struct hlist_node to use as a loop counter.
833 * @n: another &struct hlist_node to use as temporary storage
834 * @head: the head for your list.
835 * @member: the name of the hlist_node within the struct.
837 #define hlist_for_each_entry_safe(tpos, pos, n, head, member) \
838 for (pos = (head)->first; \
839 pos && ({ n = pos->next; 1; }) && \
840 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
844 * hlist_for_each_entry_rcu - iterate over rcu list of given type
845 * @tpos: the type * to use as a loop counter.
846 * @pos: the &struct hlist_node to use as a loop counter.
847 * @head: the head for your list.
848 * @member: the name of the hlist_node within the struct.
850 * This list-traversal primitive may safely run concurrently with
851 * the _rcu list-mutation primitives such as hlist_add_head_rcu()
852 * as long as the traversal is guarded by rcu_read_lock().
854 #define hlist_for_each_entry_rcu(tpos, pos, head, member) \
855 for (pos = (head)->first; \
856 rcu_dereference(pos) && ({ prefetch(pos->next); 1;}) && \
857 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
861 #warning "don't include kernel headers in userspace"
862 #endif /* __KERNEL__ */