mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
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 <[email protected]> Assisted-by: LLM Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://patch.msgid.link/[email protected]
This commit is contained in:
committed by
Peter Zijlstra
parent
cd047867ee
commit
cc459ecd93
+2
-23
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user