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 empty and not being modified
285 * @head: the list to test
288 * tests whether a list is empty _and_ checks that no other CPU might be
289 * in the process of modifying either member (next or prev)
291 * NOTE: using list_empty_careful() without synchronization
292 * can only be safe if the only activity that can happen
293 * to the list entry is list_del_init(). Eg. it cannot be used
294 * if another CPU could re-list_add() it.
296 static inline int list_empty_careful(const struct list_head *head)
298 struct list_head *next = head->next;
299 return (next == head) && (next == head->prev);
302 static inline void __list_splice(struct list_head *list,
303 struct list_head *head)
305 struct list_head *first = list->next;
306 struct list_head *last = list->prev;
307 struct list_head *at = head->next;
317 * list_splice - join two lists
318 * @list: the new list to add.
319 * @head: the place to add it in the first list.
321 static inline void list_splice(struct list_head *list, struct list_head *head)
323 if (!list_empty(list))
324 __list_splice(list, head);
328 * list_splice_init - join two lists and reinitialise the emptied list.
329 * @list: the new list to add.
330 * @head: the place to add it in the first list.
332 * The list at @list is reinitialised
334 static inline void list_splice_init(struct list_head *list,
335 struct list_head *head)
337 if (!list_empty(list)) {
338 __list_splice(list, head);
339 INIT_LIST_HEAD(list);
344 * list_entry - get the struct for this entry
345 * @ptr: the &struct list_head pointer.
346 * @type: the type of the struct this is embedded in.
347 * @member: the name of the list_struct within the struct.
349 #define list_entry(ptr, type, member) \
350 container_of(ptr, type, member)
353 * list_for_each - iterate over a list
354 * @pos: the &struct list_head to use as a loop cursor.
355 * @head: the head for your list.
357 #define list_for_each(pos, head) \
358 for (pos = (head)->next; prefetch(pos->next), pos != (head); \
362 * __list_for_each - iterate over a list
363 * @pos: the &struct list_head to use as a loop cursor.
364 * @head: the head for your list.
366 * This variant differs from list_for_each() in that it's the
367 * simplest possible list iteration code, no prefetching is done.
368 * Use this for code that knows the list to be very short (empty
369 * or 1 entry) most of the time.
371 #define __list_for_each(pos, head) \
372 for (pos = (head)->next; pos != (head); pos = pos->next)
375 * list_for_each_prev - iterate over a list backwards
376 * @pos: the &struct list_head to use as a loop cursor.
377 * @head: the head for your list.
379 #define list_for_each_prev(pos, head) \
380 for (pos = (head)->prev; prefetch(pos->prev), pos != (head); \
384 * list_for_each_safe - iterate over a list safe against removal of list entry
385 * @pos: the &struct list_head to use as a loop cursor.
386 * @n: another &struct list_head to use as temporary storage
387 * @head: the head for your list.
389 #define list_for_each_safe(pos, n, head) \
390 for (pos = (head)->next, n = pos->next; pos != (head); \
391 pos = n, n = pos->next)
394 * list_for_each_entry - iterate over list of given type
395 * @pos: the type * to use as a loop cursor.
396 * @head: the head for your list.
397 * @member: the name of the list_struct within the struct.
399 #define list_for_each_entry(pos, head, member) \
400 for (pos = list_entry((head)->next, typeof(*pos), member); \
401 prefetch(pos->member.next), &pos->member != (head); \
402 pos = list_entry(pos->member.next, typeof(*pos), member))
405 * list_for_each_entry_reverse - iterate backwards over list of given type.
406 * @pos: the type * to use as a loop cursor.
407 * @head: the head for your list.
408 * @member: the name of the list_struct within the struct.
410 #define list_for_each_entry_reverse(pos, head, member) \
411 for (pos = list_entry((head)->prev, typeof(*pos), member); \
412 prefetch(pos->member.prev), &pos->member != (head); \
413 pos = list_entry(pos->member.prev, typeof(*pos), member))
416 * list_prepare_entry - prepare a pos entry for use in 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 * Prepares a pos entry for use as a start point in list_for_each_entry_continue.
423 #define list_prepare_entry(pos, head, member) \
424 ((pos) ? : list_entry(head, typeof(*pos), member))
427 * list_for_each_entry_continue - continue iteration over list of given type
428 * @pos: the type * to use as a loop cursor.
429 * @head: the head for your list.
430 * @member: the name of the list_struct within the struct.
432 * Continue to iterate over list of given type, continuing after
433 * the current position.
435 #define list_for_each_entry_continue(pos, head, member) \
436 for (pos = list_entry(pos->member.next, typeof(*pos), member); \
437 prefetch(pos->member.next), &pos->member != (head); \
438 pos = list_entry(pos->member.next, typeof(*pos), member))
441 * list_for_each_entry_from - iterate over list of given type from the current point
442 * @pos: the type * to use as a loop cursor.
443 * @head: the head for your list.
444 * @member: the name of the list_struct within the struct.
446 * Iterate over list of given type, continuing from current position.
448 #define list_for_each_entry_from(pos, head, member) \
449 for (; prefetch(pos->member.next), &pos->member != (head); \
450 pos = list_entry(pos->member.next, typeof(*pos), member))
453 * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
454 * @pos: the type * to use as a loop cursor.
455 * @n: another type * to use as temporary storage
456 * @head: the head for your list.
457 * @member: the name of the list_struct within the struct.
459 #define list_for_each_entry_safe(pos, n, head, member) \
460 for (pos = list_entry((head)->next, typeof(*pos), member), \
461 n = list_entry(pos->member.next, typeof(*pos), member); \
462 &pos->member != (head); \
463 pos = n, n = list_entry(n->member.next, typeof(*n), member))
466 * list_for_each_entry_safe_continue
467 * @pos: the type * to use as a loop cursor.
468 * @n: another type * to use as temporary storage
469 * @head: the head for your list.
470 * @member: the name of the list_struct within the struct.
472 * Iterate over list of given type, continuing after current point,
473 * safe against removal of list entry.
475 #define list_for_each_entry_safe_continue(pos, n, head, member) \
476 for (pos = list_entry(pos->member.next, typeof(*pos), member), \
477 n = list_entry(pos->member.next, typeof(*pos), member); \
478 &pos->member != (head); \
479 pos = n, n = list_entry(n->member.next, typeof(*n), member))
482 * list_for_each_entry_safe_from
483 * @pos: the type * to use as a loop cursor.
484 * @n: another type * to use as temporary storage
485 * @head: the head for your list.
486 * @member: the name of the list_struct within the struct.
488 * Iterate over list of given type from current point, safe against
489 * removal of list entry.
491 #define list_for_each_entry_safe_from(pos, n, head, member) \
492 for (n = list_entry(pos->member.next, typeof(*pos), member); \
493 &pos->member != (head); \
494 pos = n, n = list_entry(n->member.next, typeof(*n), member))
497 * list_for_each_entry_safe_reverse
498 * @pos: the type * to use as a loop cursor.
499 * @n: another type * to use as temporary storage
500 * @head: the head for your list.
501 * @member: the name of the list_struct within the struct.
503 * Iterate backwards over list of given type, safe against removal
506 #define list_for_each_entry_safe_reverse(pos, n, head, member) \
507 for (pos = list_entry((head)->prev, typeof(*pos), member), \
508 n = list_entry(pos->member.prev, typeof(*pos), member); \
509 &pos->member != (head); \
510 pos = n, n = list_entry(n->member.prev, typeof(*n), member))
513 * list_for_each_rcu - iterate over an rcu-protected list
514 * @pos: the &struct list_head to use as a loop cursor.
515 * @head: the head for your list.
517 * This list-traversal primitive may safely run concurrently with
518 * the _rcu list-mutation primitives such as list_add_rcu()
519 * as long as the traversal is guarded by rcu_read_lock().
521 #define list_for_each_rcu(pos, head) \
522 for (pos = (head)->next; \
523 prefetch(rcu_dereference(pos)->next), pos != (head); \
526 #define __list_for_each_rcu(pos, head) \
527 for (pos = (head)->next; \
528 rcu_dereference(pos) != (head); \
532 * list_for_each_safe_rcu
533 * @pos: the &struct list_head to use as a loop cursor.
534 * @n: another &struct list_head to use as temporary storage
535 * @head: the head for your list.
537 * Iterate over an rcu-protected list, safe against removal of list entry.
539 * This list-traversal primitive may safely run concurrently with
540 * the _rcu list-mutation primitives such as list_add_rcu()
541 * as long as the traversal is guarded by rcu_read_lock().
543 #define list_for_each_safe_rcu(pos, n, head) \
544 for (pos = (head)->next; \
545 n = rcu_dereference(pos)->next, pos != (head); \
549 * list_for_each_entry_rcu - iterate over rcu list of given type
550 * @pos: the type * to use as a loop cursor.
551 * @head: the head for your list.
552 * @member: the name of the list_struct within the struct.
554 * This list-traversal primitive may safely run concurrently with
555 * the _rcu list-mutation primitives such as list_add_rcu()
556 * as long as the traversal is guarded by rcu_read_lock().
558 #define list_for_each_entry_rcu(pos, head, member) \
559 for (pos = list_entry((head)->next, typeof(*pos), member); \
560 prefetch(rcu_dereference(pos)->member.next), \
561 &pos->member != (head); \
562 pos = list_entry(pos->member.next, typeof(*pos), member))
566 * list_for_each_continue_rcu
567 * @pos: the &struct list_head to use as a loop cursor.
568 * @head: the head for your list.
570 * Iterate over an rcu-protected list, continuing after current point.
572 * This list-traversal primitive may safely run concurrently with
573 * the _rcu list-mutation primitives such as list_add_rcu()
574 * as long as the traversal is guarded by rcu_read_lock().
576 #define list_for_each_continue_rcu(pos, head) \
577 for ((pos) = (pos)->next; \
578 prefetch(rcu_dereference((pos))->next), (pos) != (head); \
582 * Double linked lists with a single pointer list head.
583 * Mostly useful for hash tables where the two pointer list head is
585 * You lose the ability to access the tail in O(1).
589 struct hlist_node *first;
593 struct hlist_node *next, **pprev;
596 #define HLIST_HEAD_INIT { .first = NULL }
597 #define HLIST_HEAD(name) struct hlist_head name = { .first = NULL }
598 #define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
599 static inline void INIT_HLIST_NODE(struct hlist_node *h)
605 static inline int hlist_unhashed(const struct hlist_node *h)
610 static inline int hlist_empty(const struct hlist_head *h)
615 static inline void __hlist_del(struct hlist_node *n)
617 struct hlist_node *next = n->next;
618 struct hlist_node **pprev = n->pprev;
624 static inline void hlist_del(struct hlist_node *n)
627 n->next = LIST_POISON1;
628 n->pprev = LIST_POISON2;
632 * hlist_del_rcu - deletes entry from hash list without re-initialization
633 * @n: the element to delete from the hash list.
635 * Note: list_unhashed() on entry does not return true after this,
636 * the entry is in an undefined state. It is useful for RCU based
637 * lockfree traversal.
639 * In particular, it means that we can not poison the forward
640 * pointers that may still be used for walking the hash list.
642 * The caller must take whatever precautions are necessary
643 * (such as holding appropriate locks) to avoid racing
644 * with another list-mutation primitive, such as hlist_add_head_rcu()
645 * or hlist_del_rcu(), running on this same list.
646 * However, it is perfectly legal to run concurrently with
647 * the _rcu list-traversal primitives, such as
648 * hlist_for_each_entry().
650 static inline void hlist_del_rcu(struct hlist_node *n)
653 n->pprev = LIST_POISON2;
656 static inline void hlist_del_init(struct hlist_node *n)
658 if (!hlist_unhashed(n)) {
665 * hlist_replace_rcu - replace old entry by new one
666 * @old : the element to be replaced
667 * @new : the new element to insert
669 * The old entry will be replaced with the new entry atomically.
671 static inline void hlist_replace_rcu(struct hlist_node *old,
672 struct hlist_node *new)
674 struct hlist_node *next = old->next;
677 new->pprev = old->pprev;
680 new->next->pprev = &new->next;
682 old->pprev = LIST_POISON2;
685 static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
687 struct hlist_node *first = h->first;
690 first->pprev = &n->next;
692 n->pprev = &h->first;
698 * @n: the element to add to the hash list.
699 * @h: the list to add to.
702 * Adds the specified element to the specified hlist,
703 * while permitting racing traversals.
705 * The caller must take whatever precautions are necessary
706 * (such as holding appropriate locks) to avoid racing
707 * with another list-mutation primitive, such as hlist_add_head_rcu()
708 * or hlist_del_rcu(), running on this same list.
709 * However, it is perfectly legal to run concurrently with
710 * the _rcu list-traversal primitives, such as
711 * hlist_for_each_entry_rcu(), used to prevent memory-consistency
712 * problems on Alpha CPUs. Regardless of the type of CPU, the
713 * list-traversal primitive must be guarded by rcu_read_lock().
715 static inline void hlist_add_head_rcu(struct hlist_node *n,
716 struct hlist_head *h)
718 struct hlist_node *first = h->first;
720 n->pprev = &h->first;
723 first->pprev = &n->next;
727 /* next must be != NULL */
728 static inline void hlist_add_before(struct hlist_node *n,
729 struct hlist_node *next)
731 n->pprev = next->pprev;
733 next->pprev = &n->next;
737 static inline void hlist_add_after(struct hlist_node *n,
738 struct hlist_node *next)
740 next->next = n->next;
742 next->pprev = &n->next;
745 next->next->pprev = &next->next;
749 * hlist_add_before_rcu
750 * @n: the new element to add to the hash list.
751 * @next: the existing element to add the new element before.
754 * Adds the specified element to the specified hlist
755 * before the specified node while permitting racing traversals.
757 * The caller must take whatever precautions are necessary
758 * (such as holding appropriate locks) to avoid racing
759 * with another list-mutation primitive, such as hlist_add_head_rcu()
760 * or hlist_del_rcu(), running on this same list.
761 * However, it is perfectly legal to run concurrently with
762 * the _rcu list-traversal primitives, such as
763 * hlist_for_each_entry_rcu(), used to prevent memory-consistency
764 * problems on Alpha CPUs.
766 static inline void hlist_add_before_rcu(struct hlist_node *n,
767 struct hlist_node *next)
769 n->pprev = next->pprev;
772 next->pprev = &n->next;
777 * hlist_add_after_rcu
778 * @prev: the existing element to add the new element after.
779 * @n: the new element to add to the hash list.
782 * Adds the specified element to the specified hlist
783 * after the specified node while permitting racing traversals.
785 * The caller must take whatever precautions are necessary
786 * (such as holding appropriate locks) to avoid racing
787 * with another list-mutation primitive, such as hlist_add_head_rcu()
788 * or hlist_del_rcu(), running on this same list.
789 * However, it is perfectly legal to run concurrently with
790 * the _rcu list-traversal primitives, such as
791 * hlist_for_each_entry_rcu(), used to prevent memory-consistency
792 * problems on Alpha CPUs.
794 static inline void hlist_add_after_rcu(struct hlist_node *prev,
795 struct hlist_node *n)
797 n->next = prev->next;
798 n->pprev = &prev->next;
802 n->next->pprev = &n->next;
805 #define hlist_entry(ptr, type, member) container_of(ptr,type,member)
807 #define hlist_for_each(pos, head) \
808 for (pos = (head)->first; pos && ({ prefetch(pos->next); 1; }); \
811 #define hlist_for_each_safe(pos, n, head) \
812 for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
816 * hlist_for_each_entry - iterate over list of given type
817 * @tpos: the type * to use as a loop cursor.
818 * @pos: the &struct hlist_node to use as a loop cursor.
819 * @head: the head for your list.
820 * @member: the name of the hlist_node within the struct.
822 #define hlist_for_each_entry(tpos, pos, head, member) \
823 for (pos = (head)->first; \
824 pos && ({ prefetch(pos->next); 1;}) && \
825 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
829 * hlist_for_each_entry_continue - iterate over a hlist continuing after current point
830 * @tpos: the type * to use as a loop cursor.
831 * @pos: the &struct hlist_node to use as a loop cursor.
832 * @member: the name of the hlist_node within the struct.
834 #define hlist_for_each_entry_continue(tpos, pos, member) \
835 for (pos = (pos)->next; \
836 pos && ({ prefetch(pos->next); 1;}) && \
837 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
841 * hlist_for_each_entry_from - iterate over a hlist continuing from current point
842 * @tpos: the type * to use as a loop cursor.
843 * @pos: the &struct hlist_node to use as a loop cursor.
844 * @member: the name of the hlist_node within the struct.
846 #define hlist_for_each_entry_from(tpos, pos, member) \
847 for (; pos && ({ prefetch(pos->next); 1;}) && \
848 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
852 * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
853 * @tpos: the type * to use as a loop cursor.
854 * @pos: the &struct hlist_node to use as a loop cursor.
855 * @n: another &struct hlist_node to use as temporary storage
856 * @head: the head for your list.
857 * @member: the name of the hlist_node within the struct.
859 #define hlist_for_each_entry_safe(tpos, pos, n, head, member) \
860 for (pos = (head)->first; \
861 pos && ({ n = pos->next; 1; }) && \
862 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
866 * hlist_for_each_entry_rcu - iterate over rcu list of given type
867 * @tpos: the type * to use as a loop cursor.
868 * @pos: the &struct hlist_node to use as a loop cursor.
869 * @head: the head for your list.
870 * @member: the name of the hlist_node within the struct.
872 * This list-traversal primitive may safely run concurrently with
873 * the _rcu list-mutation primitives such as hlist_add_head_rcu()
874 * as long as the traversal is guarded by rcu_read_lock().
876 #define hlist_for_each_entry_rcu(tpos, pos, head, member) \
877 for (pos = (head)->first; \
878 rcu_dereference(pos) && ({ prefetch(pos->next); 1;}) && \
879 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
883 #warning "don't include kernel headers in userspace"
884 #endif /* __KERNEL__ */