Skip to contentSkip to conversation

+ rbtree-add-rbtree_postorder_for_each_entry_safe-helper.patch added to -mm tree

PATCH [email protected] 1 participant 1 message Jul 29, 2013

lore
Share & tools
lore
#0 lore raw

Subject: + rbtree-add-rbtree_postorder_for_each_entry_safe-helper.patch added to -mm tree
To: [email protected],[email protected],[email protected],[email protected],[email protected]
From: [email protected]
Date: Mon, 29 Jul 2013 15:43:56 -0700

The patch titled
Subject: rbtree: add rbtree_postorder_for_each_entry_safe() helper
has been added to the -mm tree. Its filename is
rbtree-add-rbtree_postorder_for_each_entry_safe-helper.patch

This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/rbtree-add-rbtree_postorder_for_each_entry_safe-helper.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/rbtree-add-rbtree_postorder_for_each_entry_safe-helper.patch

Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated there every 3-4 working days

------------------------------------------------------
From: Cody P Schafer <[email protected]>
Subject: rbtree: add rbtree_postorder_for_each_entry_safe() helper

Because deletion (of the entire tree) is a relatively common use of the rbtree_postorder iteration, and because doing it safely means fiddling with temporary storage, provide a helper to simplify postorder rbtree iteration.

---

 include/linux/rbtree.h |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
include/linux/rbtree.h renamed from include/linux/rbtree.h~rbtree-add-rbtree_postorder_for_each_entry_safe-helper +18 -0
diff -puN include/linux/rbtree.h~rbtree-add-rbtree_postorder_for_each_entry_safe-helper include/linux/rbtree.h
@@ -85,4 +85,22 @@ static inline void rb_link_node(struct r
 	*rb_link = node;
 }
 
+/**
+ * rbtree_postorder_for_each_entry_safe - iterate over rb_root in post order of
+ * given type safe against removal of rb_node entry
+ *
+ * @pos:	the 'type *' to use as a loop cursor.
+ * @n:		another 'type *' to use as temporary storage
+ * @root:	'rb_root *' of the rbtree.
+ * @field:	the name of the rb_node field within 'type'.
+ */
+#define rbtree_postorder_for_each_entry_safe(pos, n, root, field) \
+	for (pos = rb_entry(rb_first_postorder(root), typeof(*pos), field),\
+		n = rb_entry(rb_next_postorder(&pos->field), \
+			typeof(*pos), field); \
+	     &pos->field; \
+	     pos = n, \
+		n = rb_entry(rb_next_postorder(&pos->field), \
+			typeof(*pos), field))
+
 #endif	/* _LINUX_RBTREE_H */

_

Patches currently in -mm which might be from [email protected] are

mm-page_alloc-restructure-free-page-stealing-code-and-fix-a-bug.patch mm-page_alloc-restructure-free-page-stealing-code-and-fix-a-bug-fix.patch mm-fix-the-value-of-fallback_migratetype-in-alloc_extfrag-tracepoint.patch rbtree-add-postorder-iteration-functions.patch rbtree-add-rbtree_postorder_for_each_entry_safe-helper.patch rbtree_test-add-test-for-postorder-iteration.patch rbtree-allow-tests-to-run-as-builtin.patch mm-zswap-use-postorder-iteration-when-destroying-rbtree.patch