mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/
synced 2026-09-28 19:20:30 +00:00
fs/pipe: use spinlock in pipe_read() only if there is a watch_queue
If there is no watch_queue, holding the pipe mutex is enough to prevent concurrent writes, and we can avoid the spinlock. O_NOTIFICATION_QUEUE is an exotic and rarely used feature, and of all the pipes that exist at any given time, only very few actually have a watch_queue, therefore it appears worthwile to optimize the common case. This patch does not optimize pipe_resize_ring() where the spinlocks could be avoided as well; that does not seem like a worthwile optimization because this function is not called often. Related commits: - commit8df441294d("pipe: Check for ring full inside of the spinlock in pipe_write()") - commitb667b86734("pipe: Advance tail pointer inside of wait spinlock in pipe_read()") - commit189b0ddc24("pipe: Fix missing lock in pipe_resize_ring()") Signed-off-by: Max Kellermann <max.kellermann@ionos.com> Message-Id: <20230921075755.1378787-4-max.kellermann@ionos.com> Reviewed-by: David Howells <dhowells@redhat.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
dfaabf916b
commit
478dbf1217
1 changed files with 32 additions and 11 deletions
43
fs/pipe.c
43
fs/pipe.c
Loading…
Add table
Add a link
Reference in a new issue