diff options
author | stephen hemminger <shemminger@vyatta.com> | 2010-02-22 02:57:17 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-02-22 18:45:54 -0500 |
commit | 1cc523271ef0b6305c565a143e3d48f6fff826dd (patch) | |
tree | 8acfcce42d5d81e4ce993c078985bfc3789bf2c5 /include | |
parent | 35e2da46d25a53e0e19956f533cc29272a6cceb2 (diff) |
seq_file: add RCU versions of new hlist/list iterators (v3)
Many usages of seq_file use RCU protected lists, so non RCU
iterators will not work safely.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/rculist.h | 5 | ||||
-rw-r--r-- | include/linux/seq_file.h | 15 |
2 files changed, 16 insertions, 4 deletions
diff --git a/include/linux/rculist.h b/include/linux/rculist.h index 1bf0f708c4f..701fe9cb552 100644 --- a/include/linux/rculist.h +++ b/include/linux/rculist.h | |||
@@ -406,6 +406,11 @@ static inline void hlist_add_after_rcu(struct hlist_node *prev, | |||
406 | n->next->pprev = &n->next; | 406 | n->next->pprev = &n->next; |
407 | } | 407 | } |
408 | 408 | ||
409 | #define __hlist_for_each_rcu(pos, head) \ | ||
410 | for (pos = rcu_dereference((head)->first); \ | ||
411 | pos && ({ prefetch(pos->next); 1; }); \ | ||
412 | pos = rcu_dereference(pos->next)) | ||
413 | |||
409 | /** | 414 | /** |
410 | * hlist_for_each_entry_rcu - iterate over rcu list of given type | 415 | * hlist_for_each_entry_rcu - iterate over rcu list of given type |
411 | * @tpos: the type * to use as a loop cursor. | 416 | * @tpos: the type * to use as a loop cursor. |
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h index c95bcdc18f4..03c0232b416 100644 --- a/include/linux/seq_file.h +++ b/include/linux/seq_file.h | |||
@@ -140,10 +140,17 @@ extern struct list_head *seq_list_next(void *v, struct list_head *head, | |||
140 | */ | 140 | */ |
141 | 141 | ||
142 | extern struct hlist_node *seq_hlist_start(struct hlist_head *head, | 142 | extern struct hlist_node *seq_hlist_start(struct hlist_head *head, |
143 | loff_t pos); | 143 | loff_t pos); |
144 | extern struct hlist_node *seq_hlist_start_head(struct hlist_head *head, | 144 | extern struct hlist_node *seq_hlist_start_head(struct hlist_head *head, |
145 | loff_t pos); | 145 | loff_t pos); |
146 | extern struct hlist_node *seq_hlist_next(void *v, struct hlist_head *head, | 146 | extern struct hlist_node *seq_hlist_next(void *v, struct hlist_head *head, |
147 | loff_t *ppos); | 147 | loff_t *ppos); |
148 | 148 | ||
149 | extern struct hlist_node *seq_hlist_start_rcu(struct hlist_head *head, | ||
150 | loff_t pos); | ||
151 | extern struct hlist_node *seq_hlist_start_head_rcu(struct hlist_head *head, | ||
152 | loff_t pos); | ||
153 | extern struct hlist_node *seq_hlist_next_rcu(void *v, | ||
154 | struct hlist_head *head, | ||
155 | loff_t *ppos); | ||
149 | #endif | 156 | #endif |