]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ksmbd: server: avoid busy polling in accept loop
authorQingfang Deng <dqfext@gmail.com>
Mon, 17 Nov 2025 08:59:00 +0000 (16:59 +0800)
committerSteve French <stfrench@microsoft.com>
Mon, 1 Dec 2025 03:11:45 +0000 (21:11 -0600)
commit3316a8fc840d82fad5efcf76ad0ea3f76fdca209
treefdba40238c9cfd570f3579ea272291dd854f3e68
parent5003ad718af7705d6a519445a897843fac88167a
ksmbd: server: avoid busy polling in accept loop

The ksmbd listener thread was using busy waiting on a listening socket by
calling kernel_accept() with SOCK_NONBLOCK and retrying every 100ms on
-EAGAIN. Since this thread is dedicated to accepting new connections,
there is no need for non-blocking mode.

Switch to a blocking accept() call instead, allowing the thread to sleep
until a new connection arrives. This avoids unnecessary wakeups and CPU
usage. During teardown, call shutdown() on the listening socket so that
accept() returns -EINVAL and the thread exits cleanly.

The socket release mutex is redundant because kthread_stop() blocks until
the listener thread returns, guaranteeing safe teardown ordering.

Also remove sk_rcvtimeo and sk_sndtimeo assignments, which only caused
accept() to return -EAGAIN prematurely.

Signed-off-by: Qingfang Deng <dqfext@gmail.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/server/transport_tcp.c