From e0d3582ad65aaefb5c3fa912f681b1eeb65ddc99 Mon Sep 17 00:00:00 2001 From: jxiong Date: Tue, 17 Jun 2008 15:46:56 +0000 Subject: [PATCH] b=16046 r=nikita,isaac cl_lock_page_list optimization. For lnet: just copied the macro list_for_each_entry_safe_from from linux kernel. --- lnet/include/libcfs/list.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lnet/include/libcfs/list.h b/lnet/include/libcfs/list.h index 799d853..1ea1c01 100644 --- a/lnet/include/libcfs/list.h +++ b/lnet/include/libcfs/list.h @@ -229,6 +229,21 @@ static inline void list_splice_init(struct list_head *list, for (pos = (head)->next, n = pos->next; pos != (head); \ pos = n, n = pos->next) +/** + * list_for_each_entry_safe_from + * @pos: the type * to use as a loop cursor. + * @n: another type * to use as temporary storage + * @head: the head for your list. + * @member: the name of the list_struct within the struct. + * + * Iterate over list of given type from current point, safe against + * removal of list entry. + */ +#define list_for_each_entry_safe_from(pos, n, head, member) \ + for (n = list_entry(pos->member.next, typeof(*pos), member); \ + &pos->member != (head); \ + pos = n, n = list_entry(n->member.next, typeof(*n), member)) + /* * Double linked lists with a single pointer list head. * Mostly useful for hash tables where the two pointer list head is -- 1.8.3.1