summaryrefslogtreecommitdiff
path: root/tools/lib/python/kdoc/parse_data_structs.py
diff options
context:
space:
mode:
authorShakeel Butt <shakeel.butt@linux.dev>2026-09-09 21:54:33 -0700
committerChristian Brauner <brauner@kernel.org>2026-09-17 11:38:34 +0200
commit5ad03af184342c760a83a18dba32043f7cec24c6 (patch)
tree9bfc318b1b6c6448bc61cc6df4dfdfdce140dae1 /tools/lib/python/kdoc/parse_data_structs.py
parent7f24d0f60b1087dbc28d68398957c18774e5a7d8 (diff)
downloadlinux-next-5ad03af184342c760a83a18dba32043f7cec24c6.tar.gz
linux-next-5ad03af184342c760a83a18dba32043f7cec24c6.zip
kernfs: allocate the open node outside the open file mutex
kernfs_get_open_node() allocates the kernfs_open_node while holding one of the hashed kernfs_open_file mutexes, so opening a file nobody has open yet can enter reclaim with that mutex held. The mutex is shared by every node that hashes to it, so unrelated opens, closes and xattr updates in the same bucket wait. It is the most contended lock in kernfs on our fleet: 2.19M waiters over 29 days, more than two hundred times the waiters on kernfs_rwsem, and the highest median hold of any kernfs lock at 77ms. Most of it is monitoring daemons opening cgroup control files, and the open node is freed once the last descriptor closes, so an open-read-close loop allocates every time. Look at kn->attr.open before taking the mutex, and allocate then if nothing has the file open. Should the peek be wrong, which needs the last descriptor to close inside the window, fall back to allocating under the mutex as before. Eight tasks opening and closing four cgroup files 20000 times each, with lock_stat on the hashed mutex: contentions hold total hold avg before 198 4.19 s 8.67 us after 119 2.31 s 4.78 us and the same number of acquisitions either way. This does not empty the bucket. kernfs_fop_release() and kernfs_xattr_set() still sleep under the same mutex. It stops opens doing it. Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev> Link: https://patch.msgid.link/20260910045433.489413-1-shakeel.butt@linux.dev Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Diffstat (limited to 'tools/lib/python/kdoc/parse_data_structs.py')
0 files changed, 0 insertions, 0 deletions