From: Christian Brauner <brauner@kernel.org>
To: Josef Bacik <josef@toxicpanda.com>, Jeff Layton <jlayton@kernel.org>
Cc: "Paul E. McKenney" <paulmck@kernel.org>,
Peter Ziljstra <peterz@infradead.org>,
linux-fsdevel@vger.kernel.org,
Christian Brauner <brauner@kernel.org>
Subject: [PATCH v2 0/8] fs: lockless mntns lookup
Date: Thu, 12 Dec 2024 12:55:59 +0100 [thread overview]
Message-ID: <20241212-work-mount-rbtree-lockless-v2-0-4fe6cef02534@kernel.org> (raw)
Hey,
Currently we take the read lock when looking for a mount namespace to
list mounts in. We can make this lockless. The simple search case can
just use a sequence counter to detect concurrent changes to the rbtree.
For walking the list of mount namespaces sequentially via nsfs we keep a
separate rcu list as rb_prev() and rb_next() aren't usable safely with
rcu.
Since creating mount namespaces is a relatively rare event compared with
querying mounts in a foreign mount namespace this is worth it. Once
libmount and systemd pick up this mechanism to list mounts in foreign
mount namespaces this will be used very frequently.
doing.
Thanks!
Christian
---
Changes in v2:
- Remove mnt_ns_find_it_at() by switching to rb_find_rcu().
- Add separate list to lookup sequential mount namespaces.
- Link to v1: https://lore.kernel.org/r/20241210-work-mount-rbtree-lockless-v1-0-338366b9bbe4@kernel.org
---
Christian Brauner (8):
mount: remove inlude/nospec.h include
fs: add mount namespace to rbtree late
fs: lockless mntns rbtree lookup
rculist: add list_bidir_{del,prev}_rcu()
fs: lockless mntns lookup for nsfs
fs: simplify rwlock to spinlock
selftests: remove unneeded include
samples: add test-list-all-mounts
fs/mount.h | 20 +--
fs/namespace.c | 158 ++++++++++++++---------
fs/nsfs.c | 5 +-
include/linux/rculist.h | 43 +++++++
samples/vfs/.gitignore | 1 +
samples/vfs/Makefile | 2 +-
samples/vfs/test-list-all-mounts.c | 235 ++++++++++++++++++++++++++++++++++
tools/testing/selftests/pidfd/pidfd.h | 1 -
8 files changed, 387 insertions(+), 78 deletions(-)
---
base-commit: 40384c840ea1944d7c5a392e8975ed088ecf0b37
change-id: 20241207-work-mount-rbtree-lockless-7d4071b74f18
next reply other threads:[~2024-12-12 11:56 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-12 11:55 Christian Brauner [this message]
2024-12-12 11:56 ` [PATCH v2 1/8] mount: remove inlude/nospec.h include Christian Brauner
2024-12-12 11:56 ` [PATCH v2 2/8] fs: add mount namespace to rbtree late Christian Brauner
2024-12-12 11:56 ` [PATCH v2 3/8] fs: lockless mntns rbtree lookup Christian Brauner
2024-12-12 12:09 ` Peter Zijlstra
2024-12-12 17:35 ` Christian Brauner
2024-12-12 12:15 ` Jeff Layton
2024-12-12 17:34 ` Christian Brauner
2024-12-12 11:56 ` [PATCH v2 4/8] rculist: add list_bidir_{del,prev}_rcu() Christian Brauner
2024-12-12 15:18 ` Paul E. McKenney
2024-12-12 17:40 ` Christian Brauner
2024-12-12 18:27 ` Paul E. McKenney
2024-12-12 11:56 ` [PATCH v2 5/8] fs: lockless mntns lookup for nsfs Christian Brauner
2024-12-12 12:48 ` Peter Zijlstra
2024-12-12 17:33 ` Christian Brauner
2024-12-12 18:24 ` Christian Brauner
2024-12-12 11:56 ` [PATCH v2 6/8] fs: simplify rwlock to spinlock Christian Brauner
2024-12-12 11:56 ` [PATCH v2 7/8] selftests: remove unneeded include Christian Brauner
2024-12-12 11:56 ` [PATCH v2 8/8] samples: add test-list-all-mounts Christian Brauner
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=20241212-work-mount-rbtree-lockless-v2-0-4fe6cef02534@kernel.org \
--to=brauner@kernel.org \
--cc=jlayton@kernel.org \
--cc=josef@toxicpanda.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.