From: Davidlohr Bueso <dave@stgolabs.net>
To: akpm@linux-foundation.org
Cc: dave@stgolabs.net, linux-kernel@vger.kernel.org,
mcgrof@kernel.org, broonie@kernel.org,
alex.williamson@redhat.com
Subject: [PATCH -next 0/5] rbtree: optimize frequent tree walks
Date: Fri, 7 Feb 2020 10:03:00 -0800 [thread overview]
Message-ID: <20200207180305.11092-1-dave@stgolabs.net> (raw)
This series introduces the ll_rbtree interface to optimize rbtree users
that incur in frequent in-order tree iterations (even full traversals).
This can be seen as an abstraction to what is already done for dealing
with VMAs (albeit non-augmented trees).
Mainly, it trades off higher per-node memory footprint (two extra pointers)
for minimal runtime overhead to gain O(1) brachless next and prev node
pointers. See patch 1 for full details, but, for example, the following
tables show the benefits vs the costs of using this new interface.
+--------+--------------+-----------+
| #nodes | plain rbtree | ll-rbtree |
+--------+--------------+-----------+
| 10 | 138 | 24 |
| 100 | 7,200 | 425 |
| 1000 | 17,000 | 8,000 |
| 10000 | 501,090 | 222,500 |
+--------+--------------+-----------+
While there are other node representations that optimize getting such pointers
without bloating the nodes as much, such as keeping a parent pointer or threaded
trees where the nil prev/next pointers are recycled; both incurring in higher
runtime penalization for common modification operations as well as any rotations.
The overhead of tree modifications can be seen in the following table, comparing
cycles to insert+delete:
+--------+--------------+------------------+-----------+
| #nodes | plain rbtree | augmented rbtree | ll-rbtree |
+--------+--------------+------------------+-----------+
| 10 | 530 | 840 | 600 |
| 100 | 7,100 | 14,200 | 7,800 |
| 1000 | 265,000 | 370,000 | 205,200 |
| 10000 | 4,400,000 | 5,500,000 | 4,200,000 |
+--------+--------------+------------------+-----------+
Patch 1 introduces the ll_rbtree machinery.
Patches 2-5 convert users that might benefit from the new interface.
Full details and justifications for the conversion are in each
individual patch.
I am Cc'ing some of the maintainers of the users I have converted to the whole
series such that it can the numbers and interface details can be easily seen.
Please consider for v5.7.
Thanks!
Davidlohr Bueso (5):
lib/rbtree: introduce linked-list rbtree interface
proc/sysctl: optimize proc_sys_readdir
regmap: optimize sync() and drop() regcache callbacks
vfio/type1: optimize dma_list tree iterations
uprobes: optimize build_probe_list()
Documentation/rbtree.txt | 74 ++++++++++++++++++++++++
drivers/base/regmap/regcache-rbtree.c | 62 +++++++++++---------
drivers/vfio/vfio_iommu_type1.c | 50 +++++++++--------
fs/proc/proc_sysctl.c | 37 ++++++------
include/linux/ll_rbtree.h | 103 ++++++++++++++++++++++++++++++++++
include/linux/sysctl.h | 6 +-
kernel/events/uprobes.c | 47 ++++++++--------
7 files changed, 286 insertions(+), 93 deletions(-)
create mode 100644 include/linux/ll_rbtree.h
--
2.16.4
next reply other threads:[~2020-02-07 18:14 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-07 18:03 Davidlohr Bueso [this message]
2020-02-07 18:03 ` [PATCH 1/5] lib/rbtree: introduce linked-list rbtree interface Davidlohr Bueso
2020-02-10 20:07 ` Luis Chamberlain
2020-02-10 21:28 ` Davidlohr Bueso
2020-02-10 21:44 ` Luis Chamberlain
2020-02-07 18:03 ` [PATCH 2/5] proc/sysctl: optimize proc_sys_readdir Davidlohr Bueso
2020-02-10 20:08 ` Luis Chamberlain
2020-02-07 18:03 ` [PATCH 3/5] regmap: optimize sync() and drop() regcache callbacks Davidlohr Bueso
2020-02-10 13:11 ` Mark Brown
2020-02-07 18:03 ` [PATCH 4/5] vfio/type1: optimize dma_list tree iterations Davidlohr Bueso
2020-02-07 18:03 ` [PATCH 5/5] uprobes: optimize build_probe_list() Davidlohr Bueso
2020-02-10 1:46 ` [PATCH -next 0/5] rbtree: optimize frequent tree walks Andrew Morton
2020-02-10 15:56 ` Davidlohr Bueso
2020-02-10 22:35 ` Andrew Morton
2020-02-13 15:50 ` Davidlohr Bueso
2020-02-11 11:20 ` Mark Brown
2020-02-13 15:55 ` Davidlohr Bueso
2020-02-13 16:56 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200207180305.11092-1-dave@stgolabs.net \
--to=dave@stgolabs.net \
--cc=akpm@linux-foundation.org \
--cc=alex.williamson@redhat.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®