Re: [PATCH V3 5/7] workqueue: Process rescuer work items one-by-one using a cursor

From: Tejun Heo

Date: Fri Nov 21 2025 - 14:05:07 EST


> static bool assign_rescuer_work(struct pool_workqueue *pwq, struct worker *rescuer)
> {
> struct worker_pool *pool = pwq->pool;
> + struct work_struct *cursor = &pwq->mayday_cursor;
> struct work_struct *work, *n;
>
> + /* from where to search */

maybe: search from the start or cursor if available

...
> + /* try to assign a work to rescue */

maybe: find the next work item to rescue

> + list_for_each_entry_safe_from(work, n, &pool->worklist, entry) {
> + if (get_work_pwq(work) == pwq && assign_work(work, rescuer, &n)) {
> pwq->stats[PWQ_STAT_RESCUED]++;
> + /* put the cursor for next search */
> + list_add_tail(&cursor->entry, &n->entry);
> + return true;
> + }
...
> @@ -5141,6 +5169,20 @@ static void init_pwq(struct pool_workqueue *pwq, struct workqueue_struct *wq,
> INIT_LIST_HEAD(&pwq->pwqs_node);
> INIT_LIST_HEAD(&pwq->mayday_node);
> kthread_init_work(&pwq->release_work, pwq_release_workfn);
> +
> + /*
> + * Set the dumpy cursor work with valid function and get_work_pwq().
^
dummy
> + *
> + * The cursor work should only be in the pwq->pool->worklist, and
> + * should never be queued, processed, flushed, cancelled or even examed
^
examined

I wonder whether this is unnecessarily verbose. Maybe just "should not be
treated as a regular work item"?

Thanks.

--
tejun