ksmbd: add use_unbound_wq module parameter for the ksmbd-io workqueue
Subsystems (3)
RFC PATCH 1/1 ksmbd: add use_unbound_wq module parameter for the ksmbd-io workqueue
The "ksmbd-io" workqueue has always been per-CPU. Commit 69635d7f4b34 ("fs: WQ_PERCPU added to alloc_workqueue users") only made that default explicit as part of the treewide transition to unbound-by-default; it was not a ksmbd-specific decision.
Per-CPU work keeps request processing on the CPU that queued it, which is good for cache locality, but it also runs work on CPUs that were isolated from workqueue noise (isolcpus=, nohz_full=) and prevents the scheduler from placing blocked or long-running workers elsewhere. Which behaviour is better depends on the workload and platform.
Add a boolean use_unbound_wq module parameter. It defaults to false, so behaviour is unchanged unless it is set; when true, "ksmbd-io" is allocated with WQ_UNBOUND instead of WQ_PERCPU. The "ksmbd-break" workqueue is already WQ_UNBOUND and is not affected.
Document the parameter in ksmbd.rst.
--- Documentation/filesystems/smb/ksmbd.rst | 6 ++++++ fs/smb/server/ksmbd_work.c | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-)
Documentation/filesystems/smb/ksmbd.rst +6 -0
@@ -158,6 +158,12 @@ How to run $ sudo modprobe ksmbd.ko + - Optional module parameter ``use_unbound_wq`` (default ``0``) makes ksmbd + use an unbound workqueue instead of a per-CPU one for request + processing, e.g. when CPUs are isolated (``isolcpus=``, ``nohz_full=``). + + $ sudo modprobe ksmbd use_unbound_wq=1 + 5. Start ksmbd user space daemon $ sudo ksmbd.mountd
fs/smb/server/ksmbd_work.c +8 -1
@@ -7,6 +7,7 @@#include <linux/mm.h> #include <linux/slab.h> #include <linux/workqueue.h> +#include <linux/moduleparam.h> #include "server.h" #include "connection.h"
@@ -18,6 +19,11 @@ static struct kmem_cache *work_cache;static struct workqueue_struct *ksmbd_wq;static struct workqueue_struct *ksmbd_break_wq; +static bool use_unbound_wq; +module_param (use_unbound_wq, bool,0444 ); +MODULE_PARM_DESC (use_unbound_wq, +"Use an unbound workqueue for request processing (default: false, per-CPU)" ); +static int ksmbd_reserve_iov (struct ksmbd_work *work,int need_iov_cnt) {struct kvec *new;
@@ -108,7 +114,8 @@ int ksmbd_work_pool_init(void)int ksmbd_workqueue_init (void ) { - ksmbd_wq =alloc_workqueue ("ksmbd-io" ,WQ_PERCPU ,0 ); + ksmbd_wq =alloc_workqueue ("ksmbd-io" , + use_unbound_wq ?WQ_UNBOUND :WQ_PERCPU ,0 );if (!ksmbd_wq)return -ENOMEM ; ksmbd_break_wq =alloc_workqueue ("ksmbd-break" ,WQ_UNBOUND ,0 );
Signature · 1 line
2.54.0
Namjae Jeon
maintainerQuoted 12 lines · Stefan Chulski
The "ksmbd-io" workqueue has always been per-CPU. Commit
69635d7f4b34("fs:WQ_PERCPUadded toalloc_workqueueusers") only made that default explicit as part of the treewide transition to unbound-by-default; it was not a ksmbd-specific decision.Per-CPU work keeps request processing on the CPU that queued it, which is good for cache locality, but it also runs work on CPUs that were isolated from workqueue noise (isolcpus=, nohz_full=) and prevents the scheduler from placing blocked or long-running workers elsewhere. Which behaviour is better depends on the workload and platform.
Quoted 8 lines
Add a boolean
use_unbound_wqmodule parameter. It defaults to false, so behaviour is unchanged unless it is set; when true, "ksmbd-io" is allocated withWQ_UNBOUNDinstead ofWQ_PERCPU. The "ksmbd-break" workqueue is alreadyWQ_UNBOUNDand is not affected.Document the parameter in
ksmbd.rst.Signed-off-by Stefan Chulski <[email protected]>
Hi Stefan,
Do you have numbers comparing the per-CPU and unbound queues, How does this compare with the earlier following RFC ?
https://lore.kernel.org/linux-cifs/[email protected]/
Thanks.
Quoted 20 lines · Namjae Jeon
Quoted 17 lines · Stefan Chulski
The "ksmbd-io" workqueue has always been per-CPU. Commit
69635d7f4b34("fs:WQ_PERCPUadded toalloc_workqueueusers") only made that default explicit as part of the treewide transition to unbound-by-default; it was not a ksmbd-specific decision.Per-CPU work keeps request processing on the CPU that queued it, which is good for cache locality, but it also runs work on CPUs that were isolated from workqueue noise (isolcpus=, nohz_full=) and prevents the scheduler from placing blocked or long-running workers elsewhere. Which behaviour is better depends on the workload and platform.
Add a boolean
use_unbound_wqmodule parameter. It defaults to false, so behaviour is unchanged unless it is set; when true, "ksmbd-io" is allocated withWQ_UNBOUNDinstead ofWQ_PERCPU. The "ksmbd-break" workqueue is alreadyWQ_UNBOUNDand is not affected.
Quoted 6 lines
Quoted 3 lines
Document the parameter in
ksmbd.rst.Signed-off-by Stefan Chulski <[email protected]>Hi Stefan,
Do you have numbers comparing the per-CPU and unbound queues,
Yes, on our systems we observed up to an 18% performance improvement when using the unbound workqueue.
The primary reason for this improvement is that with the default per-CPU workqueue, ksmbd-io work can sometimes start on a CPU that is already heavily loaded. Because it is bound to that specific CPU, the scheduler cannot move it to a less loaded or idle CPU, leading to bottlenecks. By using WQ_UNBOUND, the scheduler is free to migrate the work to less loaded CPUs, which significantly improves our CPU cycle efficiency.
Quoted 5 lines
How does this compare with the earlier following RFC ?
https://lore.kernel.org/linux-cifs/[email protected]/
Thanks.
While both address the underlying scheduling limitations of per-CPU workqueues for ksmbd, my patch introduces the use_unbound_wq module parameter rather than changing the behavior unconditionally. Because the optimal behavior (cache locality vs. load balancing) heavily depends on the specific workload and platform, this approach keeps the existing per-CPU behavior as the default while allowing platforms to easily opt-in to the unbound workqueue when it yields better performance.
Thanks,
Stefan
Namjae Jeon
maintainerQuoted 46 lines · Stefan Chulski
Quoted 20 lines · Namjae Jeon
Quoted 17 lines · Stefan Chulski
The "ksmbd-io" workqueue has always been per-CPU. Commit
69635d7f4b34("fs:WQ_PERCPUadded toalloc_workqueueusers") only made that default explicit as part of the treewide transition to unbound-by-default; it was not a ksmbd-specific decision.Per-CPU work keeps request processing on the CPU that queued it, which is good for cache locality, but it also runs work on CPUs that were isolated from workqueue noise (isolcpus=, nohz_full=) and prevents the scheduler from placing blocked or long-running workers elsewhere. Which behaviour is better depends on the workload and platform.
Add a boolean
use_unbound_wqmodule parameter. It defaults to false, so behaviour is unchanged unless it is set; when true, "ksmbd-io" is allocated withWQ_UNBOUNDinstead ofWQ_PERCPU. The "ksmbd-break" workqueue is alreadyWQ_UNBOUNDand is not affected.Quoted 6 lines
Quoted 3 lines
Document the parameter in
ksmbd.rst.Signed-off-by Stefan Chulski <[email protected]>Hi Stefan,
Do you have numbers comparing the per-CPU and unbound queues,
Yes, on our systems we observed up to an 18% performance improvement when using the unbound workqueue.
The primary reason for this improvement is that with the default per-CPU workqueue, ksmbd-io work can sometimes start on a CPU that is already heavily loaded. Because it is bound to that specific CPU, the scheduler cannot move it to a less loaded or idle CPU, leading to bottlenecks. By using
WQ_UNBOUND, the scheduler is free to migrate the work to less loaded CPUs, which significantly improves our CPU cycle efficiency.Quoted 5 lines
How does this compare with the earlier following RFC ?
https://lore.kernel.org/linux-cifs/[email protected]/
Thanks.
Quoted 8 lines
While both address the underlying scheduling limitations of per-CPU workqueues for ksmbd, my patch introduces the
use_unbound_wqmodule parameter rather than changing the behavior unconditionally. Because the optimal behavior (cache locality vs. load balancing) heavily depends on the specific workload and platform, this approach keeps the existing per-CPU behavior as the default while allowing platforms to easily opt-in to the unbound workqueue when it yields better performance.
Could you provide the benchmark setup and actual results? If WQ_UNBOUND generally performs better across representative workloads, We could make it the default and provide a module parameter to opt into WQ_PERCPU instead.
Thanks!
Quoted 3 lines
Thanks,
Stefan
Quoted 14 lines · Namjae Jeon
Quoted 11 lines · Stefan Chulski
On Mon, Nov 16, 2026 at 2:10 PM Namjae Jeon <[email protected]> wrote:
While both address the underlying scheduling limitations of per-CPU workqueues for ksmbd, my patch introduces the
use_unbound_wqmodule parameter rather than changing the behavior unconditionally. Because the optimal behavior (cache locality vs. load balancing) heavily depends on the specific workload and platform, this approach keeps the existing per-CPU behavior as the default while allowing platforms to easily opt-in to the unbound workqueue when it yields better performance.
Quoted 4 lines
Could you provide the benchmark setup and actual results? If
WQ_UNBOUNDgenerally performs better across representative workloads, We could make it the default and provide a module parameter to opt intoWQ_PERCPUinstead.
These are the results from our embedded systems featuring dual-core ARM CPUs. The benchmark setup is fairly simple: writing to a USB disk over the network. Because the network traffic is a single 5-tuple TCP stream, it is pinned to one of the CPUs (depending on the 5-tuple hash).
We tested this on two different platforms and saw the following throughput improvements:
Platform 1: Improved from 178 MB/s to 210 MB/s Platform 2: Improved from 215 MB/s to 263 MB/s
Regards,
Stefan
Namjae Jeon
maintainerQuoted 26 lines · Stefan Chulski
Quoted 14 lines · Namjae Jeon
Quoted 11 lines · Stefan Chulski
On Mon, Nov 16, 2026 at 2:10 PM Namjae Jeon <[email protected]> wrote:
While both address the underlying scheduling limitations of per-CPU workqueues for ksmbd, my patch introduces the
use_unbound_wqmodule parameter rather than changing the behavior unconditionally. Because the optimal behavior (cache locality vs. load balancing) heavily depends on the specific workload and platform, this approach keeps the existing per-CPU behavior as the default while allowing platforms to easily opt-in to the unbound workqueue when it yields better performance.Quoted 4 lines
Could you provide the benchmark setup and actual results? If
WQ_UNBOUNDgenerally performs better across representative workloads, We could make it the default and provide a module parameter to opt intoWQ_PERCPUinstead.These are the results from our embedded systems featuring dual-core ARM CPUs. The benchmark setup is fairly simple: writing to a USB disk over the network. Because the network traffic is a single 5-tuple TCP stream, it is pinned to one of the CPUs (depending on the 5-tuple hash).
Quoted 4 lines
We tested this on two different platforms and saw the following throughput improvements:
Platform 1: Improved from 178 MB/s to 210 MB/s Platform 2: Improved from 215 MB/s to 263 MB/s
Okay.
https://lore.kernel.org/linux-cifs/[email protected]/
Huiwen’s RFC also provides a write_wq module parameter, disabled by default, so both approaches keep per-CPU request processing as the default. The main difference is that Huiwen’s patch routes eligible single-channel WRITEs to a separate unbound queue, while your patch switches the entire ksmbd-io queue to unbound.
So, Could you test Huiwen’s patch series with write_wq=1 on your platform and compare the results with your patch ?
Thanks.
Hi Namjae, Stefan,
Simply routing WRITE requests to an unbound workqueue is not sufficient,
as I've observed performance regressions across a number of workloads. I've since developed a more complete approach and will post it soon.
Thanks,
Huiwen
Quoted 45 lines · Namjae Jeon
Quoted 26 lines · Stefan Chulski
Quoted 14 lines · Namjae Jeon
Quoted 11 lines · Stefan Chulski
On Mon, Nov 16, 2026 at 2:10 PM Namjae Jeon <[email protected]> wrote:
While both address the underlying scheduling limitations of per-CPU workqueues for ksmbd, my patch introduces the
use_unbound_wqmodule parameter rather than changing the behavior unconditionally. Because the optimal behavior (cache locality vs. load balancing) heavily depends on the specific workload and platform, this approach keeps the existing per-CPU behavior as the default while allowing platforms to easily opt-in to the unbound workqueue when it yields better performance.Quoted 4 lines
Could you provide the benchmark setup and actual results? If
WQ_UNBOUNDgenerally performs better across representative workloads, We could make it the default and provide a module parameter to opt intoWQ_PERCPUinstead.These are the results from our embedded systems featuring dual-core ARM CPUs. The benchmark setup is fairly simple: writing to a USB disk over the network. Because the network traffic is a single 5-tuple TCP stream, it is pinned to one of the CPUs (depending on the 5-tuple hash).
Quoted 4 lines
We tested this on two different platforms and saw the following throughput improvements:
Platform 1: Improved from 178 MB/s to 210 MB/s Platform 2: Improved from 215 MB/s to 263 MB/sOkay.
https://lore.kernel.org/linux-cifs/[email protected]/
Huiwen’s RFC also provides a
write_wqmodule parameter, disabled by default, so both approaches keep per-CPU request processing as the default. The main difference is that Huiwen’s patch routes eligible single-channel WRITEs to a separate unbound queue, while your patch switches the entire ksmbd-io queue to unbound.
So, Could you test Huiwen’s patch series with write_wq=1 on your platform and compare the results with your patch ?Thanks.
Quoted 9 lines · Huiwen He
Hi Namjae, Stefan,
Simply routing WRITE requests to an unbound workqueue is not sufficient, as I've observed performance regressions across a number of workloads. I've since developed a more complete approach and will post it soon.
Thanks,
Huiwen
Sounds good, please cc me on the new patchset when you post it. I originally tried to keep my changes as simple as possible, but I look forward to seeing your approach.
Regards,
Stefan