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

From: Tejun Heo
Date: Tue Dec 26 2023 - 15:12:56 EST


On Tue, Dec 26, 2023 at 05:14:18PM +0800, Lai Jiangshan wrote:
> 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?

Ah, I made a mistake while splitting the patches. This gets added by a later
patch but this step should have an explicit check against wq->max_active.
Lemme add a check for the unbound path.

Thanks.

--
tejun