All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/10] fs: lockless mntns lookup
@ 2024-12-12 23:03 Christian Brauner
  2024-12-12 23:03 ` [PATCH v3 01/10] mount: remove inlude/nospec.h include Christian Brauner
                   ` (10 more replies)
  0 siblings, 11 replies; 20+ messages in thread
From: Christian Brauner @ 2024-12-12 23:03 UTC (permalink / raw)
  To: Josef Bacik, Jeff Layton
  Cc: Paul E. McKenney, Peter Ziljstra, linux-fsdevel,
	Christian Brauner

Hey,

This now also includes selftests for iterating mount namespaces both
backwards and forwards.

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.

Thanks!
Christian

---
Changes in v3:
- Add selftests.
- Put list_head into a union with the wait_queue_head_t for poll instead
  of the mnt_ns_tree_node which would've risked breaking rbtree
  traversal.
- Handle insertion into the mount namespace list correctly by making use
  of the rbtree position information after the mount namespace has been
  added to it.
- Improve the documentation for the new list_bidir_{del,prev}_rcu().
- Link to v2: https://lore.kernel.org/r/20241212-work-mount-rbtree-lockless-v2-0-4fe6cef02534@kernel.org

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 (10):
      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
      seltests: move nsfs into filesystems subfolder
      selftests: add tests for mntns iteration
      selftests: remove unneeded include
      samples: add test-list-all-mounts

 fs/mount.h                                         |  18 +-
 fs/namespace.c                                     | 163 ++++++++------
 fs/nsfs.c                                          |   5 +-
 include/linux/rculist.h                            |  47 +++++
 samples/vfs/.gitignore                             |   1 +
 samples/vfs/Makefile                               |   2 +-
 samples/vfs/test-list-all-mounts.c                 | 235 +++++++++++++++++++++
 .../selftests/{ => filesystems}/nsfs/.gitignore    |   1 +
 .../selftests/{ => filesystems}/nsfs/Makefile      |   4 +-
 .../selftests/{ => filesystems}/nsfs/config        |   0
 .../selftests/filesystems/nsfs/iterate_mntns.c     | 149 +++++++++++++
 .../selftests/{ => filesystems}/nsfs/owner.c       |   0
 .../selftests/{ => filesystems}/nsfs/pidns.c       |   0
 tools/testing/selftests/pidfd/pidfd.h              |   1 -
 14 files changed, 546 insertions(+), 80 deletions(-)
---
base-commit: 40384c840ea1944d7c5a392e8975ed088ecf0b37
change-id: 20241207-work-mount-rbtree-lockless-7d4071b74f18


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2024-12-19 13:46 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-12 23:03 [PATCH v3 00/10] fs: lockless mntns lookup Christian Brauner
2024-12-12 23:03 ` [PATCH v3 01/10] mount: remove inlude/nospec.h include Christian Brauner
2024-12-12 23:03 ` [PATCH v3 02/10] fs: add mount namespace to rbtree late Christian Brauner
2024-12-12 23:03 ` [PATCH v3 03/10] fs: lockless mntns rbtree lookup Christian Brauner
2024-12-13  8:50   ` Peter Zijlstra
2024-12-13 14:11   ` Jeff Layton
2024-12-13 18:44     ` Christian Brauner
2024-12-13 19:02       ` Jeff Layton
2024-12-19  9:20   ` Lai, Yi
2024-12-19 13:45     ` Christian Brauner
2024-12-12 23:03 ` [PATCH v3 04/10] rculist: add list_bidir_{del,prev}_rcu() Christian Brauner
2024-12-13  0:42   ` Paul E. McKenney
2024-12-13 13:49     ` Christian Brauner
2024-12-12 23:03 ` [PATCH v3 05/10] fs: lockless mntns lookup for nsfs Christian Brauner
2024-12-12 23:03 ` [PATCH v3 06/10] fs: simplify rwlock to spinlock Christian Brauner
2024-12-12 23:03 ` [PATCH v3 07/10] seltests: move nsfs into filesystems subfolder Christian Brauner
2024-12-12 23:03 ` [PATCH v3 08/10] selftests: add tests for mntns iteration Christian Brauner
2024-12-12 23:03 ` [PATCH v3 09/10] selftests: remove unneeded include Christian Brauner
2024-12-12 23:03 ` [PATCH v3 10/10] samples: add test-list-all-mounts Christian Brauner
2024-12-13 19:03 ` [PATCH v3 00/10] fs: lockless mntns lookup Jeff Layton

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.