summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYiwei Lin <s921975628@gmail.com>2026-10-05 17:32:36 +0800
committerPeter Zijlstra <peterz@infradead.org>2026-10-13 13:51:28 +0200
commitcc459ecd9388d96dc20404b157f5a4eedb66c355 (patch)
tree8b005e22a9a3c95bb69b809261f9e0098dd2c8b5 /lib
parentcd047867ee5fc7c47cf9461c8a59c7117de9f680 (diff)
downloadlinux-cc459ecd9388d96dc20404b157f5a4eedb66c355.tar.gz
linux-cc459ecd9388d96dc20404b157f5a4eedb66c355.zip
rbtree_test: Use rb_add_augmented_cached() for the cached augmented test
insert_augmented_cached() open-codes the descent that the generic rb_add_augmented_cached() helper provides. Use the helper instead, so that rbtree_test covers it: it is what sched/eevdf relies on and nothing in lib/ exercises it today. Signed-off-by: Yiwei Lin <s921975628@gmail.com> Assisted-by: LLM Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://patch.msgid.link/20261005093236.62702-5-s921975628@gmail.com
Diffstat (limited to 'lib')
-rw-r--r--lib/rbtree_test.c25
1 files changed, 2 insertions, 23 deletions
diff --git a/lib/rbtree_test.c b/lib/rbtree_test.c
index c1386d328cfb..00f62e4f9d10 100644
--- a/lib/rbtree_test.c
+++ b/lib/rbtree_test.c
@@ -89,29 +89,8 @@ static void insert_augmented(struct test_node *node,
static void insert_augmented_cached(struct test_node *node,
struct rb_root_cached *root)
{
- struct rb_node **new = &root->rb_root.rb_node, *rb_parent = NULL;
- u32 key = node->key;
- u32 val = node->val;
- struct test_node *parent;
- bool leftmost = true;
-
- while (*new) {
- rb_parent = *new;
- parent = rb_entry(rb_parent, struct test_node, rb);
- if (parent->augmented < val)
- parent->augmented = val;
- if (key < parent->key)
- new = &parent->rb.rb_left;
- else {
- new = &parent->rb.rb_right;
- leftmost = false;
- }
- }
-
- node->augmented = val;
- rb_link_node(&node->rb, rb_parent, new);
- rb_insert_augmented_cached(&node->rb, root,
- leftmost, &augment_callbacks);
+ node->augmented = node->val;
+ rb_add_augmented_cached(&node->rb, root, less, &augment_callbacks);
}