From: Tejun Heo <tj@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Lai Jiangshan <jiangshanlai@gmail.com>,
Breno Leitao <leitao@debian.org>, Yao Kai <yaokai34@huawei.com>,
liuyongqiang <liuyongqiang13@huawei.com>,
Tejun Heo <tj@kernel.org>
Subject: [PATCHSET wq/for-7.4] workqueue: Make flush_workqueue() cost scale with active pwqs
Date: Tue, 1 Sep 2026 11:09:26 -1000 [thread overview]
Message-ID: <20260901210929.3092513-1-tj@kernel.org> (raw)
Hello,
Since 636b927eba5b ("workqueue: Make unbound workqueues to use per-cpu
pool_workqueues"), flush_workqueue() walks one pwq per possible CPU, cycling
each pool lock, even when the workqueue is idle. Yao Kai reported the XFS
CIL workqueue, flushed on every log force, spending up to 64us per flush in
that walk on a 128-CPU machine.
This patchset makes flushes visit only the pwqs which have been active since
the last flush by tracking them on per-node lists. On a 192-CPU 2-node
machine, flushing an idle per-cpu workqueue goes from 40k to 4.2M per second
and 16 threads doing queue+flush in a loop go from 30k to 110k flushes per
second. Dense flushes with every pwq active get 15-20% slower on unbound
workqueues.
Yao, can you please test whether this resolves the fsync latencies you
reported?
This patchset contains the following three patches:
0001-workqueue-Add-for_each_node_with_fallback.patch
0002-workqueue-Maintain-pwq-total_in_flight.patch
0003-workqueue-Make-flush_workqueue-visit-only-pwqs-activ.patch
0001-0002 are prep patches. 0003 implements the active pwq lists.
The patchset is on top of wq/for-7.4 (ab85b68e630e) and also available in
the following git branch:
git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git wq-flush-active-pwq-lists
diffstat follows. Thanks.
kernel/workqueue.c | 301 ++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 238 insertions(+), 63 deletions(-)
--
tejun
next reply other threads:[~2026-09-01 21:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 21:09 Tejun Heo [this message]
2026-09-01 21:09 ` [PATCH 1/3] workqueue: Add for_each_node_with_fallback() Tejun Heo
2026-09-01 21:09 ` [PATCH 2/3] workqueue: Maintain pwq->total_in_flight Tejun Heo
2026-09-01 21:09 ` [PATCH 3/3] workqueue: Make flush_workqueue() visit only pwqs active since the last flush 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=20260901210929.3092513-1-tj@kernel.org \
--to=tj@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuyongqiang13@huawei.com \
--cc=yaokai34@huawei.com \
/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®