Re: [PATCH V4 3/4] workqueue: Limit number of processed works in rescuer per turn

From: Tejun Heo

Date: Wed Dec 03 2025 - 14:41:11 EST


Hello, Lai.

On Wed, Dec 03, 2025 at 11:22:32AM +0800, Lai Jiangshan wrote:
> On Wed, Dec 3, 2025 at 2:16 AM Tejun Heo <tj@xxxxxxxxxx> wrote:
...
> > Alternatively, just
> > separate out the pwq rotation into a separate function, so that the caller
> > can do
> >
> > while (assign_rescuer_work(..)) {
> > process_scheduled_works(rescuer);
> > if (++count > RESCUER_BATCH) {
> > rotate mayday list;
>
> The current implementation of the cursor cannot be processed by workers as a
> regular work item, which means it has no pwq reference and cannot be left
> behind if the pwq is not put back on the mayday list. As a result, the code
> here has to handle the cursor explicitly, which adds extra burden to
> understanding the code.

I'm probably missing something but what prevents rescuer_thread() from just
not calling assign_rescuer_work() and just call send_mayday() on the pwq?
send_mayday() currently takes @work but all it cares about is pwq, so we can
just pass in pwq.

Thanks.

--
tejun