* [PATCH] rbtree: add comment to rb_insert_augmented()
@ 2014-09-17 2:25 Lai Jiangshan
2014-09-17 2:29 ` Michel Lespinasse
0 siblings, 1 reply; 2+ messages in thread
From: Lai Jiangshan @ 2014-09-17 2:25 UTC (permalink / raw)
To: linux-kernel; +Cc: Lai Jiangshan, Andrew Morton, Michel Lespinasse
The comment is copied from Documentation/rbtree.txt, but this comment
is so important that it should also be in the code.
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Michel Lespinasse <walken@google.com>
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
include/linux/rbtree_augmented.h | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/include/linux/rbtree_augmented.h b/include/linux/rbtree_augmented.h
index fea49b5..378c5ee 100644
--- a/include/linux/rbtree_augmented.h
+++ b/include/linux/rbtree_augmented.h
@@ -43,6 +43,16 @@ struct rb_augment_callbacks {
extern void __rb_insert_augmented(struct rb_node *node, struct rb_root *root,
void (*augment_rotate)(struct rb_node *old, struct rb_node *new));
+/*
+ * Fixup the rbtree and update the augmented information when rebalancing.
+ *
+ * On insertion, the user must update the augmented information on the path
+ * leading to the inserted node, then call rb_link_node() as usual and
+ * rb_augment_inserted() instead of the usual rb_insert_color() call.
+ * If rb_augment_inserted() rebalances the rbtree, it will callback into
+ * a user provided function to update the augmented information on the
+ * affected subtrees.
+ */
static inline void
rb_insert_augmented(struct rb_node *node, struct rb_root *root,
const struct rb_augment_callbacks *augment)
--
1.7.4.4
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] rbtree: add comment to rb_insert_augmented()
2014-09-17 2:25 [PATCH] rbtree: add comment to rb_insert_augmented() Lai Jiangshan
@ 2014-09-17 2:29 ` Michel Lespinasse
0 siblings, 0 replies; 2+ messages in thread
From: Michel Lespinasse @ 2014-09-17 2:29 UTC (permalink / raw)
To: Lai Jiangshan; +Cc: linux-kernel, Andrew Morton
On Tue, Sep 16, 2014 at 7:25 PM, Lai Jiangshan <laijs@cn.fujitsu.com> wrote:
> The comment is copied from Documentation/rbtree.txt, but this comment
> is so important that it should also be in the code.
>
> CC: Andrew Morton <akpm@linux-foundation.org>
> CC: Michel Lespinasse <walken@google.com>
> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Looks good, thanks for proposing this.
Acked-by: Michel Lespinasse <walken@google.com>
--
Michel "Walken" Lespinasse
A program is never fully debugged until the last user dies.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-09-17 2:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-17 2:25 [PATCH] rbtree: add comment to rb_insert_augmented() Lai Jiangshan
2014-09-17 2:29 ` Michel Lespinasse
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®