Commit 3316a8f
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>1 parent 5003ad7 commit 3316a8f
1 file changed
Lines changed: 6 additions & 35 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
| |||
56 | 55 | | |
57 | 56 | | |
58 | 57 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | 58 | | |
73 | 59 | | |
74 | 60 | | |
| |||
236 | 222 | | |
237 | 223 | | |
238 | 224 | | |
239 | | - | |
240 | 225 | | |
241 | | - | |
242 | 226 | | |
243 | 227 | | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
251 | 232 | | |
252 | | - | |
253 | 233 | | |
254 | 234 | | |
255 | 235 | | |
| |||
458 | 438 | | |
459 | 439 | | |
460 | 440 | | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | 441 | | |
466 | 442 | | |
467 | 443 | | |
| |||
532 | 508 | | |
533 | 509 | | |
534 | 510 | | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | 511 | | |
539 | 512 | | |
540 | 513 | | |
| |||
604 | 577 | | |
605 | 578 | | |
606 | 579 | | |
| 580 | + | |
607 | 581 | | |
608 | 582 | | |
609 | | - | |
610 | | - | |
| 583 | + | |
611 | 584 | | |
612 | | - | |
613 | 585 | | |
614 | 586 | | |
615 | 587 | | |
| |||
672 | 644 | | |
673 | 645 | | |
674 | 646 | | |
675 | | - | |
676 | 647 | | |
677 | 648 | | |
678 | 649 | | |
| |||
0 commit comments