hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/lib/rbtree.c
....@@ -1,22 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 Red Black Trees
34 (C) 1999 Andrea Arcangeli <andrea@suse.de>
45 (C) 2002 David Woodhouse <dwmw2@infradead.org>
56 (C) 2012 Michel Lespinasse <walken@google.com>
67
7
- This program is free software; you can redistribute it and/or modify
8
- it under the terms of the GNU General Public License as published by
9
- the Free Software Foundation; either version 2 of the License, or
10
- (at your option) any later version.
11
-
12
- This program is distributed in the hope that it will be useful,
13
- but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- GNU General Public License for more details.
16
-
17
- You should have received a copy of the GNU General Public License
18
- along with this program; if not, write to the Free Software
19
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
208
219 linux/lib/rbtree.c
2210 */
....@@ -25,7 +13,7 @@
2513 #include <linux/export.h>
2614
2715 /*
28
- * red-black trees properties: http://en.wikipedia.org/wiki/Rbtree
16
+ * red-black trees properties: https://en.wikipedia.org/wiki/Rbtree
2917 *
3018 * 1) A node is either red or black
3119 * 2) The root is black
....@@ -95,13 +83,9 @@
9583
9684 static __always_inline void
9785 __rb_insert(struct rb_node *node, struct rb_root *root,
98
- bool newleft, struct rb_node **leftmost,
9986 void (*augment_rotate)(struct rb_node *old, struct rb_node *new))
10087 {
10188 struct rb_node *parent = rb_red_parent(node), *gparent, *tmp;
102
-
103
- if (newleft)
104
- *leftmost = node;
10589
10690 while (true) {
10791 /*
....@@ -449,37 +433,18 @@
449433
450434 void rb_insert_color(struct rb_node *node, struct rb_root *root)
451435 {
452
- __rb_insert(node, root, false, NULL, dummy_rotate);
436
+ __rb_insert(node, root, dummy_rotate);
453437 }
454438 EXPORT_SYMBOL(rb_insert_color);
455439
456440 void rb_erase(struct rb_node *node, struct rb_root *root)
457441 {
458442 struct rb_node *rebalance;
459
- rebalance = __rb_erase_augmented(node, root,
460
- NULL, &dummy_callbacks);
443
+ rebalance = __rb_erase_augmented(node, root, &dummy_callbacks);
461444 if (rebalance)
462445 ____rb_erase_color(rebalance, root, dummy_rotate);
463446 }
464447 EXPORT_SYMBOL(rb_erase);
465
-
466
-void rb_insert_color_cached(struct rb_node *node,
467
- struct rb_root_cached *root, bool leftmost)
468
-{
469
- __rb_insert(node, &root->rb_root, leftmost,
470
- &root->rb_leftmost, dummy_rotate);
471
-}
472
-EXPORT_SYMBOL(rb_insert_color_cached);
473
-
474
-void rb_erase_cached(struct rb_node *node, struct rb_root_cached *root)
475
-{
476
- struct rb_node *rebalance;
477
- rebalance = __rb_erase_augmented(node, &root->rb_root,
478
- &root->rb_leftmost, &dummy_callbacks);
479
- if (rebalance)
480
- ____rb_erase_color(rebalance, &root->rb_root, dummy_rotate);
481
-}
482
-EXPORT_SYMBOL(rb_erase_cached);
483448
484449 /*
485450 * Augmented rbtree manipulation functions.
....@@ -489,10 +454,9 @@
489454 */
490455
491456 void __rb_insert_augmented(struct rb_node *node, struct rb_root *root,
492
- bool newleft, struct rb_node **leftmost,
493457 void (*augment_rotate)(struct rb_node *old, struct rb_node *new))
494458 {
495
- __rb_insert(node, root, newleft, leftmost, augment_rotate);
459
+ __rb_insert(node, root, augment_rotate);
496460 }
497461 EXPORT_SYMBOL(__rb_insert_augmented);
498462
....@@ -539,7 +503,7 @@
539503 if (node->rb_right) {
540504 node = node->rb_right;
541505 while (node->rb_left)
542
- node=node->rb_left;
506
+ node = node->rb_left;
543507 return (struct rb_node *)node;
544508 }
545509
....@@ -571,7 +535,7 @@
571535 if (node->rb_left) {
572536 node = node->rb_left;
573537 while (node->rb_right)
574
- node=node->rb_right;
538
+ node = node->rb_right;
575539 return (struct rb_node *)node;
576540 }
577541
....@@ -602,16 +566,6 @@
602566 __rb_change_child(victim, new, parent, root);
603567 }
604568 EXPORT_SYMBOL(rb_replace_node);
605
-
606
-void rb_replace_node_cached(struct rb_node *victim, struct rb_node *new,
607
- struct rb_root_cached *root)
608
-{
609
- rb_replace_node(victim, new, &root->rb_root);
610
-
611
- if (root->rb_leftmost == victim)
612
- root->rb_leftmost = new;
613
-}
614
-EXPORT_SYMBOL(rb_replace_node_cached);
615569
616570 void rb_replace_node_rcu(struct rb_node *victim, struct rb_node *new,
617571 struct rb_root *root)