lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 10 Feb 2020 13:28:32 -0800
From:   Davidlohr Bueso <dave@...olabs.net>
To:     Luis Chamberlain <mcgrof@...nel.org>
Cc:     akpm@...ux-foundation.org, linux-kernel@...r.kernel.org,
        broonie@...nel.org, alex.williamson@...hat.com,
        Davidlohr Bueso <dbueso@...e.de>
Subject: Re: [PATCH 1/5] lib/rbtree: introduce linked-list rbtree interface

On Mon, 10 Feb 2020, Luis Chamberlain wrote:

>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?

Yes, compared to regular rb_next() 'branchless' would be unnecessary.

However compared to other node representations that are easier on
the memory footprint (parent pointers or threaded trees) also have
O(1) but still have branches - but most importantly, these approaches
incur in higher overhead for modifications to the tree.

>
>> 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.

I don't think we want an all or nothing approach as different users in the
kernel have different needs and some users are simply unable to deal with
enlarging data structures, while others have no problem.

>...

>> +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.

Right. We piggyback from the node info we already have available ie when user
iterates down the tree to find a point of insertion.

>
>Also, what about a selftest for this?

So we have lib/rbtree_test.c which does functional+latency testing - which I am
planning on updating if this series is merged. I first have some patches that
improve the overall module that are unrelated to this series and therefore
did not send it.

>
>Reviewed-by: Luis Chamberlain <mcgrof@...nel.org>

Thanks,
Davidlohr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ