aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/list.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/list.h')
-rw-r--r--include/linux/list.h46
1 files changed, 23 insertions, 23 deletions
diff --git a/include/linux/list.h b/include/linux/list.h
index e6ec59682274..fbfca73355a3 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -442,12 +442,14 @@ static inline void list_splice_init(struct list_head *list,
442 * as long as the traversal is guarded by rcu_read_lock(). 442 * as long as the traversal is guarded by rcu_read_lock().
443 */ 443 */
444#define list_for_each_rcu(pos, head) \ 444#define list_for_each_rcu(pos, head) \
445 for (pos = (head)->next; prefetch(pos->next), pos != (head); \ 445 for (pos = (head)->next; \
446 pos = rcu_dereference(pos->next)) 446 prefetch(rcu_dereference(pos)->next), pos != (head); \
447 pos = pos->next)
447 448
448#define __list_for_each_rcu(pos, head) \ 449#define __list_for_each_rcu(pos, head) \
449 for (pos = (head)->next; pos != (head); \ 450 for (pos = (head)->next; \
450 pos = rcu_dereference(pos->next)) 451 rcu_dereference(pos) != (head); \
452 pos = pos->next)
451 453
452/** 454/**
453 * list_for_each_safe_rcu - iterate over an rcu-protected list safe 455 * list_for_each_safe_rcu - iterate over an rcu-protected list safe
@@ -461,8 +463,9 @@ static inline void list_splice_init(struct list_head *list,
461 * as long as the traversal is guarded by rcu_read_lock(). 463 * as long as the traversal is guarded by rcu_read_lock().
462 */ 464 */
463#define list_for_each_safe_rcu(pos, n, head) \ 465#define list_for_each_safe_rcu(pos, n, head) \
464 for (pos = (head)->next, n = pos->next; pos != (head); \ 466 for (pos = (head)->next; \
465 pos = rcu_dereference(n), n = pos->next) 467 n = rcu_dereference(pos)->next, pos != (head); \
468 pos = n)
466 469
467/** 470/**
468 * list_for_each_entry_rcu - iterate over rcu list of given type 471 * list_for_each_entry_rcu - iterate over rcu list of given type
@@ -474,11 +477,11 @@ static inline void list_splice_init(struct list_head *list,
474 * the _rcu list-mutation primitives such as list_add_rcu() 477 * the _rcu list-mutation primitives such as list_add_rcu()
475 * as long as the traversal is guarded by rcu_read_lock(). 478 * as long as the traversal is guarded by rcu_read_lock().
476 */ 479 */
477#define list_for_each_entry_rcu(pos, head, member) \ 480#define list_for_each_entry_rcu(pos, head, member) \
478 for (pos = list_entry((head)->next, typeof(*pos), member); \ 481 for (pos = list_entry((head)->next, typeof(*pos), member); \
479 prefetch(pos->member.next), &pos->member != (head); \ 482 prefetch(rcu_dereference(pos)->member.next), \
480 pos = rcu_dereference(list_entry(pos->member.next, \ 483 &pos->member != (head); \
481 typeof(*pos), member))) 484 pos = list_entry(pos->member.next, typeof(*pos), member))
482 485
483 486
484/** 487/**
@@ -492,8 +495,9 @@ static inline void list_splice_init(struct list_head *list,
492 * as long as the traversal is guarded by rcu_read_lock(). 495 * as long as the traversal is guarded by rcu_read_lock().
493 */ 496 */
494#define list_for_each_continue_rcu(pos, head) \ 497#define list_for_each_continue_rcu(pos, head) \
495 for ((pos) = (pos)->next; prefetch((pos)->next), (pos) != (head); \ 498 for ((pos) = (pos)->next; \
496 (pos) = rcu_dereference((pos)->next)) 499 prefetch(rcu_dereference((pos))->next), (pos) != (head); \
500 (pos) = (pos)->next)
497 501
498/* 502/*
499 * Double linked lists with a single pointer list head. 503 * Double linked lists with a single pointer list head.
@@ -597,7 +601,7 @@ static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
597 * or hlist_del_rcu(), running on this same list. 601 * or hlist_del_rcu(), running on this same list.
598 * However, it is perfectly legal to run concurrently with 602 * However, it is perfectly legal to run concurrently with
599 * the _rcu list-traversal primitives, such as 603 * the _rcu list-traversal primitives, such as
600 * hlist_for_each_rcu(), used to prevent memory-consistency 604 * hlist_for_each_entry_rcu(), used to prevent memory-consistency
601 * problems on Alpha CPUs. Regardless of the type of CPU, the 605 * problems on Alpha CPUs. Regardless of the type of CPU, the
602 * list-traversal primitive must be guarded by rcu_read_lock(). 606 * list-traversal primitive must be guarded by rcu_read_lock().
603 */ 607 */
@@ -646,7 +650,7 @@ static inline void hlist_add_after(struct hlist_node *n,
646 * or hlist_del_rcu(), running on this same list. 650 * or hlist_del_rcu(), running on this same list.
647 * However, it is perfectly legal to run concurrently with 651 * However, it is perfectly legal to run concurrently with
648 * the _rcu list-traversal primitives, such as 652 * the _rcu list-traversal primitives, such as
649 * hlist_for_each_rcu(), used to prevent memory-consistency 653 * hlist_for_each_entry_rcu(), used to prevent memory-consistency
650 * problems on Alpha CPUs. 654 * problems on Alpha CPUs.
651 */ 655 */
652static inline void hlist_add_before_rcu(struct hlist_node *n, 656static inline void hlist_add_before_rcu(struct hlist_node *n,
@@ -671,7 +675,7 @@ static inline void hlist_add_before_rcu(struct hlist_node *n,
671 * or hlist_del_rcu(), running on this same list. 675 * or hlist_del_rcu(), running on this same list.
672 * However, it is perfectly legal to run concurrently with 676 * However, it is perfectly legal to run concurrently with
673 * the _rcu list-traversal primitives, such as 677 * the _rcu list-traversal primitives, such as
674 * hlist_for_each_rcu(), used to prevent memory-consistency 678 * hlist_for_each_entry_rcu(), used to prevent memory-consistency
675 * problems on Alpha CPUs. 679 * problems on Alpha CPUs.
676 */ 680 */
677static inline void hlist_add_after_rcu(struct hlist_node *prev, 681static inline void hlist_add_after_rcu(struct hlist_node *prev,
@@ -695,10 +699,6 @@ static inline void hlist_add_after_rcu(struct hlist_node *prev,
695 for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \ 699 for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
696 pos = n) 700 pos = n)
697 701
698#define hlist_for_each_rcu(pos, head) \
699 for ((pos) = (head)->first; pos && ({ prefetch((pos)->next); 1; }); \
700 (pos) = rcu_dereference((pos)->next))
701
702/** 702/**
703 * hlist_for_each_entry - iterate over list of given type 703 * hlist_for_each_entry - iterate over list of given type
704 * @tpos: the type * to use as a loop counter. 704 * @tpos: the type * to use as a loop counter.
@@ -751,7 +751,7 @@ static inline void hlist_add_after_rcu(struct hlist_node *prev,
751 751
752/** 752/**
753 * hlist_for_each_entry_rcu - iterate over rcu list of given type 753 * hlist_for_each_entry_rcu - iterate over rcu list of given type
754 * @pos: the type * to use as a loop counter. 754 * @tpos: the type * to use as a loop counter.
755 * @pos: the &struct hlist_node to use as a loop counter. 755 * @pos: the &struct hlist_node to use as a loop counter.
756 * @head: the head for your list. 756 * @head: the head for your list.
757 * @member: the name of the hlist_node within the struct. 757 * @member: the name of the hlist_node within the struct.
@@ -762,9 +762,9 @@ static inline void hlist_add_after_rcu(struct hlist_node *prev,
762 */ 762 */
763#define hlist_for_each_entry_rcu(tpos, pos, head, member) \ 763#define hlist_for_each_entry_rcu(tpos, pos, head, member) \
764 for (pos = (head)->first; \ 764 for (pos = (head)->first; \
765 pos && ({ prefetch(pos->next); 1;}) && \ 765 rcu_dereference(pos) && ({ prefetch(pos->next); 1;}) && \
766 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ 766 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
767 pos = rcu_dereference(pos->next)) 767 pos = pos->next)
768 768
769#else 769#else
770#warning "don't include kernel headers in userspace" 770#warning "don't include kernel headers in userspace"