From: Yao Kai <yaokai34@huawei.com>
To: Tejun Heo <tj@kernel.org>, Lai Jiangshan <jiangshanlai@gmail.com>
Cc: <linux-kernel@vger.kernel.org>, liuyongqiang <liuyongqiang13@huawei.com>
Subject: [QUESTION] workqueue: Reducing flush_workqueue() overhead for unbound workqueues
Date: Tue, 1 Sep 2026 16:46:06 +0800 [thread overview]
Message-ID: <0a030145-c108-4365-ba2d-ac1973a1e352@huawei.com> (raw)
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
next reply other threads:[~2026-09-01 8:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 8:46 Yao Kai [this message]
2026-09-01 21:11 ` Tejun Heo
2026-09-07 2:19 ` Yao Kai
2026-09-08 17:35 ` Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0a030145-c108-4365-ba2d-ac1973a1e352@huawei.com \
--to=yaokai34@huawei.com \
--cc=jiangshanlai@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=liuyongqiang13@huawei.com \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®