fs/pipe: write to ->poll_usage only once
PATCH 1/1 fs/pipe: write to ->poll_usage only once
Both GNU and BSD makes share a "token pipe" between their instances, as a result a -j $BIGNUM invocation results in multicore perf problems in the poll handler.
Avoiding the store will reduce it a little bit. However, the crux of the problem is the locked queuing up in poll_wait().
---
disclaimer: could not be bothered to bench this
fs/pipe.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/pipe.c +2 -1
@@ -664,7 +664,8 @@ pipe_poll(struct file *filp, poll_table *wait)union pipe_index idx;/* Epoll has some historical nasty semantics, this enables them */ -WRITE_ONCE (pipe->poll_usage, true); +if (unlikely (!READ_ONCE (pipe->poll_usage))) +WRITE_ONCE (pipe->poll_usage, true);/* * Reading pipe state only -- no need for acquiring the semaphore.
Signature · 1 line
2.48.1
Quoted 8 lines · Mateusz Guzik
Both GNU and BSD makes share a "token pipe" between their instances, as a result a -j $BIGNUM invocation results in multicore perf problems in the poll handler.
Avoiding the store will reduce it a little bit. However, the crux of the problem is the locked queuing up in
poll_wait().[...]
Applied to the vfs-7.2.misc branch of the vfs/vfs.git tree. Patches in the vfs-7.2.misc branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs-7.2.misc
[1/1] fs/pipe: write to ->poll_usage only once
https://git.kernel.org/vfs/vfs/c/e125daf61ff6
Quoted 8 lines · Mateusz Guzik
Both GNU and BSD makes share a "token pipe" between their instances, as a result a -j $BIGNUM invocation results in multicore perf problems in the poll handler.
Avoiding the store will reduce it a little bit. However, the crux of the problem is the locked queuing up in
poll_wait().Signed-off-by Mateusz Guzik <[email protected]>
I guess doesn't harm to reduce cacheline invalidations. Feel free to add:
Honza
Quoted 24 lines
---
disclaimer: could not be bothered to bench this
fs/pipe.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/pipe.c +2
-1@@ -664,7 +664,8 @@ pipe_poll(struct file *filp, poll_table *wait)union pipe_index idx;/* Epoll has some historical nasty semantics, this enables them */ -WRITE_ONCE (pipe->poll_usage, true); +if (unlikely (!READ_ONCE (pipe->poll_usage))) +WRITE_ONCE (pipe->poll_usage, true);/* * Reading pipe state only -- no need for acquiring the semaphore. Signature · 1 line
2.48.1
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR