mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: linux-kernel@vger.kernel.org,
	Lai Jiangshan <jiangshan.ljs@antgroup.com>,
	ying chen <yc1082463@gmail.com>
Subject: Re: [PATCH] workqueue: Process rescuer work items one-by-one using a positional marker
Date: Fri, 14 Nov 2025 03:31:28 -1000	[thread overview]
Message-ID: <aRcvMPAkGKqTaWJn@slm.duckdns.org> (raw)
In-Reply-To: <CAJhGHyBD2Kbv27ahkbJqMzdHJotCdozmFuGceN+TbW5+rTRyPg@mail.gmail.com>

Hello,

On Fri, Nov 14, 2025 at 10:41:04AM +0800, Lai Jiangshan wrote:
> > Also, I wonder whether it'd be simpler to think about if we just exclude the
> > work item from flush color management. e.g. we can just flag the work item
> > and then make work scanning skip them, so that they really are just markers;
> > then, we don't have to worry about colors or othre states at all. We just
> > insert the marker and use it purely as iteration marker.
> 
> I think it should be processable by the normal workers, so that we don't
> have to add special code in the fast path in worker_thread(), and it should work
> like a normal work item or the wq_barrier.

I don't know. I don't think a single unlikely() test is going to be
noticeable.

> The ability of processable by the normal workers has an additional benefit:
> if it is processed by a normal worker rather than the rescuer, this
> indicates that the pool has made forward progress by normal workers
> and  the pwq does not need to be rescued until the next mayday event.

Is that correct tho? A worker thread executes any work item on the list and
the pool may be shared by any number of workqueues, so the cursor can be
cleared without any of the work items that belong to the rescuer's workqueue
being executed, no?

> It intended to update the positional work color to avoid back-to-back
> work items to
> stall the flush_workqueue().
> 
> But it did it wrong. Maybe this is better:
> 
> if (get_work_color(*work_data_bits(&pwq->mayday_pos_work)) != pwq->work_color) {
> {
>   remove_mayday_pos(pwq);
>   insert_mayday_pos(pwq, n);
> } else {
>   list_move_tail(&pwq->mayday_pos_work.entry, &n->entry);
> }

The colored flush mechanism is already complex enough and difficult wrap
one's head around. I don't really like adding more complications there.

Thanks.

-- 
tejun

      reply	other threads:[~2025-11-14 13:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-13 16:34 Lai Jiangshan
2025-11-13 16:52 ` Lai Jiangshan
2025-11-13 17:15 ` Tejun Heo
2025-11-14  2:41   ` Lai Jiangshan
2025-11-14 13:31     ` Tejun Heo [this message]

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=aRcvMPAkGKqTaWJn@slm.duckdns.org \
    --to=tj@kernel.org \
    --cc=jiangshan.ljs@antgroup.com \
    --cc=jiangshanlai@gmail.com \
    --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®