From: Tejun Heo <tj@kernel.org>
To: ying chen <yc1082463@gmail.com>
Cc: corbet@lwn.net, jiangshanlai@gmail.com,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
laoar.shao@gmail.com
Subject: Re: [PATCH] workqueue: add workqueue.mayday_initial_timeout
Date: Wed, 12 Nov 2025 06:03:19 -1000 [thread overview]
Message-ID: <aRSvxyoWiqzcBj-N@slm.duckdns.org> (raw)
In-Reply-To: <CAN2Y7hwUmdFMM=mwYq7gsBpbSEBq6n0nXzmES4_=p3fDV=S+Ag@mail.gmail.com>
Hello,
On Wed, Nov 12, 2025 at 10:01:10AM +0800, ying chen wrote:
> Works that have already been scheduled will be executed sequentially
> within the rescuer thread.
> static int rescuer_thread(void *__rescuer)
> {
> ......
> /*
> * Slurp in all works issued via this workqueue and
> * process'em.
> */
> WARN_ON_ONCE(!list_empty(scheduled));
> list_for_each_entry_safe(work, n, &pool->worklist, entry) {
> if (get_work_pwq(work) == pwq) {
> if (first)
> pool->watchdog_ts = jiffies;
> move_linked_works(work, scheduled, &n);
> }
> first = false;
> }
>
> if (!list_empty(scheduled)) {
> process_scheduled_works(rescuer);
> ......
> }
Ah, I see what you mean. The slurping is to avoid potentially O(N^2)
scanning but that probably the wrong trade-off to make here. I think the
right solution is making it break out after finding the first matching work
item and loop outside so that it processes work item one by one.
Thanks.
--
tejun
next prev parent reply other threads:[~2025-11-12 16:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-11 2:52 ying chen
2025-11-11 2:55 ` Matthew Wilcox
2025-11-11 7:19 ` ying chen
2025-11-11 8:00 ` Lai Jiangshan
2025-11-11 20:40 ` Tejun Heo
2025-11-12 2:01 ` ying chen
2025-11-12 16:03 ` Tejun Heo [this message]
2025-11-13 2:34 ` ying chen
2025-11-13 16:31 ` Tejun Heo
2025-11-13 15:50 ` Lai Jiangshan
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=aRSvxyoWiqzcBj-N@slm.duckdns.org \
--to=tj@kernel.org \
--cc=corbet@lwn.net \
--cc=jiangshanlai@gmail.com \
--cc=laoar.shao@gmail.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=yc1082463@gmail.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®