Skip to content

ksmbd: allow request dispatch on an unbound workqueue

Huiwen He linux-cifs lkml 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4ksmbd: keep server in RESETTING until defaults are restoredfs/smb/server/server.c fs/smb/server/server.h+5 -40 replies
2/4ksmbd: reset the server directly on startup failurefs/smb/server/server.c+6 -60 replies
3/4workqueue: export attribute and sysfs setup helperskernel/workqueue.c+4 -00 replies
4/4ksmbd: add request workqueue mode startup optionfs/smb/server/ksmbd_netlink.h fs/smb/server/ksmbd_work.c fs/smb/server/ksmbd_work.h +3 more+85 -50 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/4] ksmbd: allow request dispatch on an unbound workqueue

From: Huiwen He <[email protected]>

ksmbd currently dispatches incoming requests to a per-CPU workqueue. Pipelined writes on a single connection can leave the receive thread and workers competing for the same CPU. An unbound workqueue lets workers use other CPUs, but the cost of cross-CPU handoffs can outweigh the gain from parallelism.

Patch 1 fixes a race that can let ksmbd accept a new startup request before reset finishes restoring the server defaults.

Patch 2 handles startup failures in the current control work item, so recovery does not depend on allocating another one.

Patch 3 exports the helpers needed to set CPU scope before sysfs registration.

Patch 4 lets ksmbd.mountd select the workqueue for all incoming SMB requests at server startup. With the companion ksmbd-tools patch, administrators can set "server request workqueue = unbound" in ksmbd.conf. The default is "percpu".

Single-channel fio throughput in MiB/s on tmpfs (schedutil, 128 CPUs, 16 jobs, iodepth 32, mixed 50/50 read/write). Both unbound scopes are non-strict (shard = cache_shard); delta compares unbound (cpu) with per-CPU.

Size I/O per-CPU unbound unbound delta
(shard) (cpu)
------------------------------------------------------------

  4 KiB    READ        294         182         243      -17.3%
  4 KiB    WRITE       251         178         177      -29.5%
  4 KiB    MIXED       263         146         199      -24.3%
  64 KiB   READ       2583        1791        2171      -15.9%
  64 KiB   WRITE      1640        1882        2013      +22.8%
  64 KiB   MIXED      2194        1503        1834      -16.4%
  256 KiB  READ       3119        3012        3127       +0.2%
  256 KiB  WRITE      2183        3155        3233      +48.1%
  256 KiB  MIXED      2906        3213        3239      +11.4%
  1 MiB    READ       3398        3259        3413       +0.5%
  1 MiB    WRITE      2047        3032        3091      +51.0%
  1 MiB    MIXED      2859        3367        3416      +19.5%

The October RFC explored using an unbound workqueue for selected WRITE requests [1].

As a follow-up, I am looking into an adaptive mode that weighs the benefits of parallelism against the costs of spreading work across CPUs. The goal is to outperform both fixed modes on most workloads and become the default.

[1] https://lore.kernel.org/r/[email protected]

Huiwen He (4):
ksmbd: keep server in RESETTING until defaults are restored
ksmbd: reset the server directly on startup failure
workqueue: export attribute and sysfs setup helpers
ksmbd: add request workqueue mode startup option

 fs/smb/server/ksmbd_netlink.h |  8 ++++-
 fs/smb/server/ksmbd_work.c    | 64 +++++++++++++++++++++++++++++++++--
 fs/smb/server/ksmbd_work.h    |  3 +-
 fs/smb/server/server.c        | 27 +++++++++------
 fs/smb/server/server.h        |  4 ++-
 fs/smb/server/transport_ipc.c |  5 +++
 kernel/workqueue.c            |  4 +++
 7 files changed, 100 insertions(+), 15 deletions(-)

base-commit: 87ff512becd45a08c44fd47a9f03e607af9ef6bd