aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/af_unix.h
diff options
context:
space:
mode:
authorKuniyuki Iwashima <[email protected]>2024-01-23 17:08:55 +0000
committerJakub Kicinski <[email protected]>2024-01-27 04:34:25 +0000
commit8b90a9f819dc2a06baae4ec1a64d875e53b824ec (patch)
tree8abbd921c8c7a8f95e30fa8508bcf41dfe47e34b /include/net/af_unix.h
parentaf_unix: Return struct unix_sock from unix_get_socket(). (diff)
downloadkernel-8b90a9f819dc2a06baae4ec1a64d875e53b824ec.tar.gz
kernel-8b90a9f819dc2a06baae4ec1a64d875e53b824ec.zip
af_unix: Run GC on only one CPU.
If more than 16000 inflight AF_UNIX sockets exist and the garbage collector is not running, unix_(dgram|stream)_sendmsg() call unix_gc(). Also, they wait for unix_gc() to complete. In unix_gc(), all inflight AF_UNIX sockets are traversed at least once, and more if they are the GC candidate. Thus, sendmsg() significantly slows down with too many inflight AF_UNIX sockets. There is a small window to invoke multiple unix_gc() instances, which will then be blocked by the same spinlock except for one. Let's convert unix_gc() to use struct work so that it will not consume CPUs unnecessarily. Note WRITE_ONCE(gc_in_progress, true) is moved before running GC. If we leave the WRITE_ONCE() as is and use the following test to call flush_work(), a process might not call it. CPU 0 CPU 1 --- --- start work and call __unix_gc() if (work_pending(&unix_gc_work) || <-- false READ_ONCE(gc_in_progress)) <-- false flush_work(); <-- missed! WRITE_ONCE(gc_in_progress, true) Signed-off-by: Kuniyuki Iwashima <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
Diffstat (limited to 'include/net/af_unix.h')
0 files changed, 0 insertions, 0 deletions