Whamcloud - gitweb
b=16046
authorjxiong <jxiong>
Tue, 17 Jun 2008 15:46:56 +0000 (15:46 +0000)
committerjxiong <jxiong>
Tue, 17 Jun 2008 15:46:56 +0000 (15:46 +0000)
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

index 799d853..1ea1c01 100644 (file)
@@ -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