X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=include%2Flinux%2Flist.h;h=33b863bcb7b9a017a7d1e8f2e870dc6318f31662;hb=9bf4aaab3e101692164d49b7ca357651eb691cb6;hp=9e0c971ded6f7284328c747d03e45e401ac59944;hpb=db216c3d5e4c040e557a50f8f5d35d5c415e8c1c;p=linux-2.6.git diff --git a/include/linux/list.h b/include/linux/list.h index 9e0c971de..33b863bcb 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -620,13 +620,12 @@ static inline void hlist_add_after(struct hlist_node *n, #define hlist_entry(ptr, type, member) container_of(ptr,type,member) -/* Cannot easily do prefetch unfortunately */ #define hlist_for_each(pos, head) \ for (pos = (head)->first; pos && ({ prefetch(pos->next); 1; }); \ pos = pos->next) #define hlist_for_each_safe(pos, n, head) \ - for (pos = (head)->first; n = pos ? pos->next : 0, pos; \ + for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \ pos = n) /** @@ -678,6 +677,24 @@ static inline void hlist_add_after(struct hlist_node *n, pos && ({ n = pos->next; 1; }) && \ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ pos = n) + +/** + * hlist_for_each_entry_rcu - iterate over rcu list of given type + * @pos: the type * to use as a loop counter. + * @pos: the &struct hlist_node to use as a loop counter. + * @head: the head for your list. + * @member: the name of the hlist_node within the struct. + * + * This list-traversal primitive may safely run concurrently with + * the _rcu list-mutation primitives such as hlist_add_rcu() + * as long as the traversal is guarded by rcu_read_lock(). + */ +#define hlist_for_each_entry_rcu(tpos, pos, head, member) \ + for (pos = (head)->first; \ + pos && ({ prefetch(pos->next); 1;}) && \ + ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ + pos = pos->next, ({ smp_read_barrier_depends(); 0; }) ) + #else #warning "don't include kernel headers in userspace" #endif /* __KERNEL__ */