* [QUESTION] workqueue: Reducing flush_workqueue() overhead for unbound workqueues
@ 2026-09-01 8:46 Yao Kai
2026-09-01 21:11 ` Tejun Heo
0 siblings, 1 reply; 2+ messages in thread
From: Yao Kai @ 2026-09-01 8:46 UTC (permalink / raw)
To: Tejun Heo, Lai Jiangshan; +Cc: linux-kernel, liuyongqiang
Hi,
I am seeing significant flush_workqueue() overhead for an unbound
workqueue with a very small concurrency requirement.
The original XFS discussion is here:
https://lore.kernel.org/all/20260827033654.1172495-1-ranhongyun1@huawei.com/T/#u
XFS creates its CIL push workqueue as:
alloc_workqueue("xfs-cil/%s",
WQ_FREEZABLE | WQ_MEM_RECLAIM | WQ_UNBOUND, 4, ...);
The CIL pipeline has at most four push works scheduled or running
concurrently. During a synchronous log force, XFS calls
flush_workqueue() before queueing the new push work. This completes
previously queued pushes and reduces the latency of waiting for the
target checkpoint.
Since commit 636b927eba5b ("workqueue: Make unbound workqueues to use
per-cpu pool_workqueues"), flush_workqueue_prep_pwqs() walks the
per-CPU pwqs of the workqueue. Commit 85f0d8e39aff ("workqueue: Reduce
expensive locks for unbound workqueue") substantially reduced the
number of pool lock operations, but the O(nr_cpu_ids) pwq traversal
remains.
On a 128-CPU, 4-NUMA-node system, with 16 threads performing sequential
writes followed by fsync, I observed:
Function per-CPU pwqs per-NUMA pwqs
------------------------- --------------- --------------
xfs_fsync_flush_log 256-1000 us 32-256 us
flush_workqueue_prep_pwqs 2-64 us 2-8 us
Dave pointed out that removing it may increase scheduling variance and
long-tail latency, and may move ordering latency to journal I/O
completion. He also suggested that changing the XFS caller would be a
workaround for an infrastructure regression, as other low-concurrency
unbound workqueues could have the same problem.
Is there a recommended way to avoid this overhead for such case,
I would appreciate guidance on how this problem should be solved.
I'm happy to prototype and benchmark the suggested approach.
Thanks,
Yao Kai
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [QUESTION] workqueue: Reducing flush_workqueue() overhead for unbound workqueues
2026-09-01 8:46 [QUESTION] workqueue: Reducing flush_workqueue() overhead for unbound workqueues Yao Kai
@ 2026-09-01 21:11 ` Tejun Heo
0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2026-09-01 21:11 UTC (permalink / raw)
To: Yao Kai; +Cc: Lai Jiangshan, Breno Leitao, linux-kernel, liuyongqiang
Hello,
On Tue, Sep 01, 2026 at 04:46:06PM +0800, Yao Kai wrote:
> Is there a recommended way to avoid this overhead for such case,
> I would appreciate guidance on how this problem should be solved.
Posted a patchset which makes flush_workqueue() visit only the pwqs which
have been active since the last flush:
https://lore.kernel.org/all/20260901210929.3092513-1-tj@kernel.org/
Can you please test whether it resolves the fsync latency issue you're
seeing?
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-01 21:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-01 8:46 [QUESTION] workqueue: Reducing flush_workqueue() overhead for unbound workqueues Yao Kai
2026-09-01 21:11 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®