Re: [PATCH] workqueue: combine judgments in the loop ofmaybe_create_worker

From: Lai Jiangshan
Date: Wed Sep 12 2018 - 22:32:30 EST


On Thu, Sep 13, 2018 at 9:51 AM <liu.song11@xxxxxxxxxx> wrote:
>
> >> From: Liu Song <liu.song11@xxxxxxxxxx>
> >>
> >> Although the 'need_to_create_worker' has been determined to be
> >> true before entering the function. However, adjusting the order
> >> of judgment can combine two judgments in the loop. Also improve
> >> the matching between logical operations and function naming.
> >>
> > >Signed-off-by: Liu Song <liu.song11@xxxxxxxxxx>
> >
> >idk, this doesn't really improve anything.
> >
> >Thanks.
> >
> >--
> >tejun
>
> Hi, tejun
> Indeed, the logic of the code has not changed.

The logic of the code is changed in the patch when create_worker()
happened to be failed.

Failed create_worker() doesn't always result to COOLDOWN due to
the possible condition changes. if (!need_to_create_worker(pool)),
it dosn't need to COOLDOWN.



> The idea that I made this change is
> that when reading the workqueue code, from 'maybe_create_worker' naming, it is
> possible to create a worker, but the implementation will definitely create a worker,
> which makes me somewhat confused. After analysis, I found the determine whether
> to create a worker before the function call. So this patch seems to be able to reduce
> the confusion between the function naming and implementation.
>
> Thanks
> Best regards