Re: [PATCH 08/10] workqueue: Introduce struct wq_node_nr_active

From: Lai Jiangshan
Date: Tue Dec 26 2023 - 04:14:37 EST


On Wed, Dec 20, 2023 at 3:26 PM Tejun Heo <tj@xxxxxxxxxx> wrote:

> @@ -1498,12 +1539,21 @@ static bool pwq_tryinc_nr_active(struct pool_workqueue *pwq)
> {
> struct workqueue_struct *wq = pwq->wq;
> struct worker_pool *pool = pwq->pool;
> - bool obtained;
> + struct wq_node_nr_active *nna = wq_node_nr_active(wq, pool->node);
> + bool obtained = false;
>
> lockdep_assert_held(&pool->lock);
>
> - obtained = pwq->nr_active < wq->max_active;
> + if (!nna) {
> + /* per-cpu workqueue, pwq->nr_active is sufficient */
> + obtained = pwq->nr_active < wq->max_active;
> + goto out;
> + }

For unbound workqueue, it is not checked against wq->max_active anymore
and it is increased unconditionally. Is it by design?


> +
> + atomic_inc(&nna->count);
> + obtained = true;
>
> +out:
> if (obtained)
> pwq->nr_active++;
> return obtained;