diff options
| author | Christian Brauner <brauner@kernel.org> | 2026-09-25 16:59:12 +0200 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2026-09-25 16:59:12 +0200 |
| commit | 1c45110a23bd7fb4a1a7d5f5a1014c5b688844ae (patch) | |
| tree | e47a3da55f54f181127057b885ded94cbf8ccdb0 /tools/lib/python | |
| parent | a2fb05f5133f83b2359b4b15d091bcf21e8b02bc (diff) | |
| parent | 09452e5114bd59ea79e05b5ca4579df898178bfd (diff) | |
| download | linux-next-1c45110a23bd7fb4a1a7d5f5a1014c5b688844ae.tar.gz linux-next-1c45110a23bd7fb4a1a7d5f5a1014c5b688844ae.zip | |
Merge patch series "kernfs: do less work under the kernfs_rwsem write lock"
Shakeel Butt <shakeel.butt@linux.dev> says:
kernfs_rwsem is per kernfs root, so sysfs and cgroupfs have one each for
the whole machine, and every create, remove and rename takes it for
writing. Whatever a writer does while holding it, everyone else waits
for. These three patches take work out of that section.
Patch 1: kernfs_add_one() links the node in, drops the lock, then calls
kernfs_activate(), which takes it again. sysfs does not create nodes
deactivated, so it pays two write locks for every file and directory.
Activate before dropping the lock. lock_stat says 1200 -> 830 write
acquisitions for creating and destroying five dummy netdevs.
Patch 2: kernfs_rename_ns() calls kstrdup_const() under the lock. It is
the only GFP_KERNEL allocation under the write lock in kernfs, so a
rename can enter reclaim with the lock held. Allocate before the lock.
Patch 3: kernfs_rename_ns() also frees the old name under the lock with
kfree_rcu_mightsleep(). When its batching allocation fails, which is
what happens under memory pressure, it falls back to synchronize_rcu().
A rename can then wait out a grace period with the lock held. Free
after the unlock.
Tested with the kernfs selftests under KASAN and lockdep.
* patches from https://patch.msgid.link/20260913021453.21507-1-shakeel.butt@linux.dev:
kernfs: free the old name outside kernfs_rwsem
kernfs: allocate the new name outside kernfs_rwsem
kernfs: activate a new node without dropping kernfs_rwsem
Link: https://patch.msgid.link/20260913021453.21507-1-shakeel.butt@linux.dev
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Diffstat (limited to 'tools/lib/python')
0 files changed, 0 insertions, 0 deletions
