On Fri, Jul 26, 2019 at 06:44:19PM -0700, Andrew Morton wrote:
> On Mon, 8 Jul 2019 05:24:09 -0700 Michel Lespinasse <wal...@google.com> wrote:
> 
> > Syncing up with v5.2, I see that there is a new use for augmented
> > rbtrees in mm/vmalloc.c which does not compile after applying my
> > patchset.
> > 
> > It's an easy fix though:
> 
> It still doesn't build.
> 
> lib/rbtree_test.c: In function check_augmented:
> lib/rbtree_test.c:225:35: error: implicit declaration of function 
> augment_recompute [-Werror=implicit-function-declaration]
>    WARN_ON_ONCE(node->augmented != augment_recompute(node));

grumpf, sorry about that. I thought I had rbtree_test enabled in my
build, but turned out I only had interval_tree_test :/

I would suggest the following fix, which reintroduces the code to compute
node->augmented as was previously done in augment_recompute():

----------- 8< ----------------

After introducing RB_DECLARE_CALLBACKS_MAX, we do not need the
augment_recompute function to recompute node->augmented during
rbtree rebalancing callbacks. However, this function was also
used in check_augmented() to verify that node->augmented was
correctly set, so we need to reintroduce the code for that check.

Signed-off-by: Michel Lespinasse <wal...@google.com>
---
 lib/rbtree_test.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/lib/rbtree_test.c b/lib/rbtree_test.c
index 1939419ba869..41ae3c7570d3 100644
--- a/lib/rbtree_test.c
+++ b/lib/rbtree_test.c
@@ -222,7 +222,20 @@ static void check_augmented(int nr_nodes)
        check(nr_nodes);
        for (rb = rb_first(&root.rb_root); rb; rb = rb_next(rb)) {
                struct test_node *node = rb_entry(rb, struct test_node, rb);
-               WARN_ON_ONCE(node->augmented != augment_recompute(node));
+               u32 subtree, max = node->val;
+               if (node->rb.rb_left) {
+                       subtree = rb_entry(node->rb.rb_left, struct test_node,
+                                          rb)->augmented;
+                       if (max < subtree)
+                               max = subtree;
+               }
+               if (node->rb.rb_right) {
+                       subtree = rb_entry(node->rb.rb_right, struct test_node,
+                                          rb)->augmented;
+                       if (max < subtree)
+                               max = subtree;
+               }
+               WARN_ON_ONCE(node->augmented != max);
        }
 }
 
-- 
Michel "Walken" Lespinasse
A program is never fully debugged until the last user dies.

Reply via email to