summaryrefslogtreecommitdiffstats
path: root/lib/rbtree.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbtree.c')
-rw-r--r--lib/rbtree.c40
1 files changed, 3 insertions, 37 deletions
diff --git a/lib/rbtree.c b/lib/rbtree.c
index 1ef6e25d031c..abc86c6a3177 100644
--- a/lib/rbtree.c
+++ b/lib/rbtree.c
@@ -83,14 +83,10 @@ __rb_rotate_set_parents(struct rb_node *old, struct rb_node *new,
83 83
84static __always_inline void 84static __always_inline void
85__rb_insert(struct rb_node *node, struct rb_root *root, 85__rb_insert(struct rb_node *node, struct rb_root *root,
86 bool newleft, struct rb_node **leftmost,
87 void (*augment_rotate)(struct rb_node *old, struct rb_node *new)) 86 void (*augment_rotate)(struct rb_node *old, struct rb_node *new))
88{ 87{
89 struct rb_node *parent = rb_red_parent(node), *gparent, *tmp; 88 struct rb_node *parent = rb_red_parent(node), *gparent, *tmp;
90 89
91 if (newleft)
92 *leftmost = node;
93
94 while (true) { 90 while (true) {
95 /* 91 /*
96 * Loop invariant: node is red. 92 * Loop invariant: node is red.
@@ -437,38 +433,19 @@ static const struct rb_augment_callbacks dummy_callbacks = {
437 433
438void rb_insert_color(struct rb_node *node, struct rb_root *root) 434void rb_insert_color(struct rb_node *node, struct rb_root *root)
439{ 435{
440 __rb_insert(node, root, false, NULL, dummy_rotate); 436 __rb_insert(node, root, dummy_rotate);
441} 437}
442EXPORT_SYMBOL(rb_insert_color); 438EXPORT_SYMBOL(rb_insert_color);
443 439
444void rb_erase(struct rb_node *node, struct rb_root *root) 440void rb_erase(struct rb_node *node, struct rb_root *root)
445{ 441{
446 struct rb_node *rebalance; 442 struct rb_node *rebalance;
447 rebalance = __rb_erase_augmented(node, root, 443 rebalance = __rb_erase_augmented(node, root, &dummy_callbacks);
448 NULL, &dummy_callbacks);
449 if (rebalance) 444 if (rebalance)
450 ____rb_erase_color(rebalance, root, dummy_rotate); 445 ____rb_erase_color(rebalance, root, dummy_rotate);
451} 446}
452EXPORT_SYMBOL(rb_erase); 447EXPORT_SYMBOL(rb_erase);
453 448
454void rb_insert_color_cached(struct rb_node *node,
455 struct rb_root_cached *root, bool leftmost)
456{
457 __rb_insert(node, &root->rb_root, leftmost,
458 &root->rb_leftmost, dummy_rotate);
459}
460EXPORT_SYMBOL(rb_insert_color_cached);
461
462void rb_erase_cached(struct rb_node *node, struct rb_root_cached *root)
463{
464 struct rb_node *rebalance;
465 rebalance = __rb_erase_augmented(node, &root->rb_root,
466 &root->rb_leftmost, &dummy_callbacks);
467 if (rebalance)
468 ____rb_erase_color(rebalance, &root->rb_root, dummy_rotate);
469}
470EXPORT_SYMBOL(rb_erase_cached);
471
472/* 449/*
473 * Augmented rbtree manipulation functions. 450 * Augmented rbtree manipulation functions.
474 * 451 *
@@ -477,10 +454,9 @@ EXPORT_SYMBOL(rb_erase_cached);
477 */ 454 */
478 455
479void __rb_insert_augmented(struct rb_node *node, struct rb_root *root, 456void __rb_insert_augmented(struct rb_node *node, struct rb_root *root,
480 bool newleft, struct rb_node **leftmost,
481 void (*augment_rotate)(struct rb_node *old, struct rb_node *new)) 457 void (*augment_rotate)(struct rb_node *old, struct rb_node *new))
482{ 458{
483 __rb_insert(node, root, newleft, leftmost, augment_rotate); 459 __rb_insert(node, root, augment_rotate);
484} 460}
485EXPORT_SYMBOL(__rb_insert_augmented); 461EXPORT_SYMBOL(__rb_insert_augmented);
486 462
@@ -591,16 +567,6 @@ void rb_replace_node(struct rb_node *victim, struct rb_node *new,
591} 567}
592EXPORT_SYMBOL(rb_replace_node); 568EXPORT_SYMBOL(rb_replace_node);
593 569
594void rb_replace_node_cached(struct rb_node *victim, struct rb_node *new,
595 struct rb_root_cached *root)
596{
597 rb_replace_node(victim, new, &root->rb_root);
598
599 if (root->rb_leftmost == victim)
600 root->rb_leftmost = new;
601}
602EXPORT_SYMBOL(rb_replace_node_cached);
603
604void rb_replace_node_rcu(struct rb_node *victim, struct rb_node *new, 570void rb_replace_node_rcu(struct rb_node *victim, struct rb_node *new,
605 struct rb_root *root) 571 struct rb_root *root)
606{ 572{