I think including the word "branchless" does injustice to the
optimization, just O(1) sells it to me more to how I read the code.
Why is the "branchless" prefix needed here?
access to the first node as well as
both its in-order successor and predecessor. This is done at the cost of higher
memory footprint: mainly additional prev and next pointers for each node. Such
benefits can be seen in this table showing the amount of cycles it takes to
do a full tree traversal:
+--------+--------------+-----------+
| #nodes | plain rbtree | ll-rbtree |
+--------+--------------+-----------+
| 10 | 138 | 24 |
| 100 | 7,200 | 425 |
| 1000 | 17,000 | 8,000 |
| 10000 | 501,090 | 222,500 |
+--------+--------------+-----------+
Sold, however I wonder if we can have *one new API* where based on just one
Kconfig you either get the two pointers or not, the performance gain
then would only be observed if this new kconfig entry is enabled. The
benefit of this is that we don't shove the performance benefit down
all user's throughts but rather this can be decided by distributions
and system integrators.
...
+Inserting data into a Linked-list rbtree
+----------------------------------------
+
+Because llrb trees can exist anywhere regular rbtrees, the steps are similar.
+The search for insertion differs from the regular search in two ways. First
+the caller must keep track of the previous node,
can you explain here why, even though its clear in the code: its because
we need to pass it as a parameter when the new node is inserted into the
rb tree.
Also, what about a selftest for this?
Reviewed-by: Luis Chamberlain <mcgrof@xxxxxxxxxx>