linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] workqueue: combine judgments in the loop of maybe_create_worker
@ 2018-09-12 13:58 liusong
  2018-09-12 15:55 ` Tejun Heo
  0 siblings, 1 reply; 3+ messages in thread
From: liusong @ 2018-09-12 13:58 UTC (permalink / raw)
  To: tj, jiangshanlai; +Cc: liu.song11, linux-kernel

From: Liu Song <liu.song11@zte.com.cn>

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@zte.com.cn>
---
 kernel/workqueue.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 78b192071ef7..3c7c90d70dcf 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1969,13 +1969,10 @@ __acquires(&pool->lock)
 	mod_timer(&pool->mayday_timer, jiffies + MAYDAY_INITIAL_TIMEOUT);
 
 	while (true) {
-		if (create_worker(pool) || !need_to_create_worker(pool))
+		if (!need_to_create_worker(pool) || create_worker(pool))
 			break;
 
 		schedule_timeout_interruptible(CREATE_COOLDOWN);
-
-		if (!need_to_create_worker(pool))
-			break;
 	}
 
 	del_timer_sync(&pool->mayday_timer);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] workqueue: combine judgments in the loop of maybe_create_worker
  2018-09-12 13:58 [PATCH] workqueue: combine judgments in the loop of maybe_create_worker liusong
@ 2018-09-12 15:55 ` Tejun Heo
       [not found]   ` <201809130951227309678@zte.com.cn>
  0 siblings, 1 reply; 3+ messages in thread
From: Tejun Heo @ 2018-09-12 15:55 UTC (permalink / raw)
  To: liusong; +Cc: jiangshanlai, liu.song11, linux-kernel

On Wed, Sep 12, 2018 at 09:58:29PM +0800, liusong@tom.com wrote:
> From: Liu Song <liu.song11@zte.com.cn>
> 
> 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@zte.com.cn>

idk, this doesn't really improve anything.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] workqueue: combine judgments in the loop ofmaybe_create_worker
       [not found]   ` <201809130951227309678@zte.com.cn>
@ 2018-09-13  2:32     ` Lai Jiangshan
  0 siblings, 0 replies; 3+ messages in thread
From: Lai Jiangshan @ 2018-09-13  2:32 UTC (permalink / raw)
  To: liu.song11; +Cc: Tejun Heo, liusong, LKML

On Thu, Sep 13, 2018 at 9:51 AM <liu.song11@zte.com.cn> wrote:
>
> >> From: Liu Song <liu.song11@zte.com.cn>
> >>
> >> 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@zte.com.cn>
> >
> >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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-09-13  2:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-12 13:58 [PATCH] workqueue: combine judgments in the loop of maybe_create_worker liusong
2018-09-12 15:55 ` Tejun Heo
     [not found]   ` <201809130951227309678@zte.com.cn>
2018-09-13  2:32     ` [PATCH] workqueue: combine judgments in the loop ofmaybe_create_worker Lai Jiangshan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).