workqueue: combine judgments in the loop of maybe_create_worker
PATCH 1/1 workqueue: combine judgments in the loop of maybe_create_worker
From: Liu Song <[email protected]>
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.
--- kernel/workqueue.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
kernel/workqueue.c +1 -4
@@ -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);
Signature · 1 line
2.17.1
Tejun Heo
maintainerQuoted 8 lines · On Wed, Sep 12, 2018 at 09:58:29PM +0800, [email protected] wrote:
From: Liu Song <[email protected]>
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 <[email protected]>
idk, this doesn't really improve anything.
Thanks.
Signature · 1 line
tejun
A message that is not in the archive (sent off-list or not yet received): [email protected]
Lai Jiangshan
reviewerRe: [PATCH] workqueue: combine judgments in the loop ofmaybe_create_worker
Quoted 12 lines · On Thu, Sep 13, 2018 at 9:51 AM <[email protected]> wrote:
Quoted 12 lines
Quoted 9 lines
From: Liu Song <[email protected]>
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 <[email protected]>idk, this doesn't really improve anything.
Quoted 7 lines
Quoted 4 lines
Thanks.
--
tejunHi, 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.
Quoted 9 lines
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