lkml.org 
[lkml]   [2022]   [Aug]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 8/8] workqueue: Move the locking out of maybe_create_worker()
Date
From: Lai Jiangshan <jiangshan.ljs@antgroup.com>

The code is cleaner if the reversed pair of unlock() and lock()
is moved into the caller.

Signed-off-by: Lai Jiangshan <jiangshan.ljs@antgroup.com>
---
kernel/workqueue.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 0d9844b81482..013ad61e67b9 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -2091,17 +2091,10 @@ static void pool_mayday_timeout(struct timer_list *t)
* sent to all rescuers with works scheduled on @pool to resolve
* possible allocation deadlock.
*
- * LOCKING:
- * raw_spin_lock_irq(pool->lock) which may be released and regrabbed
- * multiple times. Does GFP_KERNEL allocations. Called only from
- * manager.
+ * Does GFP_KERNEL allocations. Called only from manager.
*/
static void maybe_create_worker(struct worker_pool *pool)
-__releases(&pool->lock)
-__acquires(&pool->lock)
{
- raw_spin_unlock_irq(&pool->lock);
-
/* if we don't make progress in MAYDAY_INITIAL_TIMEOUT, call for help */
mod_timer(&pool->mayday_timer, jiffies + MAYDAY_INITIAL_TIMEOUT);

@@ -2116,7 +2109,6 @@ __acquires(&pool->lock)
}

del_timer_sync(&pool->mayday_timer);
- raw_spin_lock_irq(&pool->lock);
}

/**
@@ -2147,7 +2139,9 @@ static bool manage_workers(struct worker *worker)
pool->flags |= POOL_MANAGER_ACTIVE;
pool->manager = worker;

+ raw_spin_unlock_irq(&pool->lock);
maybe_create_worker(pool);
+ raw_spin_lock_irq(&pool->lock);

pool->manager = NULL;
pool->flags &= ~POOL_MANAGER_ACTIVE;
--
2.19.1.6.gb485710b
\
 
 \ /
  Last update: 2022-08-04 10:43    [W:0.109 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site