mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-09-10 15:49:01 -04:00
workqueue: split kick_pool() into kick_pool_pick()
Factor the worker selection out of kick_pool() into kick_pool_pick(), which picks and claims the worker under pool->lock but, instead of waking it, returns the worker's task via an out-param so the caller can issue the wakeup after dropping pool->lock. BH kicks and wake_cpu setup still happen under the lock. kick_pool() becomes a thin wrapper that wakes the returned task, so all existing callers keep waking under pool->lock. Pure refactor, no functional change. Signed-off-by: Breno Leitao <leitao@debian.org> Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
@@ -1258,19 +1258,27 @@ static void kick_bh_pool(struct worker_pool *pool)
|
||||
}
|
||||
|
||||
/**
|
||||
* kick_pool - wake up an idle worker if necessary
|
||||
* kick_pool_pick - select an idle worker to kick, deferring the wakeup
|
||||
* @pool: pool to kick
|
||||
* @wakep: out-param, set to the task to wake after pool->lock is dropped
|
||||
*
|
||||
* @pool may have pending work items. Wake up worker if necessary. Returns
|
||||
* whether a worker was woken up.
|
||||
* Like kick_pool() but, for a regular (non-BH) pool, returns the picked
|
||||
* worker's task via @wakep instead of waking it, so the caller can issue the
|
||||
* wakeup after dropping pool->lock (the wakeup takes rq->lock). Worker
|
||||
* selection, wake_cpu setup and the BH kick still happen under the lock.
|
||||
* Returns whether a worker was selected or kicked.
|
||||
*
|
||||
* Must be called with @pool->lock held.
|
||||
*/
|
||||
static bool kick_pool(struct worker_pool *pool)
|
||||
static bool kick_pool_pick(struct worker_pool *pool, struct task_struct **wakep)
|
||||
{
|
||||
struct worker *worker = first_idle_worker(pool);
|
||||
struct task_struct *p;
|
||||
|
||||
lockdep_assert_held(&pool->lock);
|
||||
|
||||
*wakep = NULL;
|
||||
|
||||
if (!need_more_worker(pool) || !worker)
|
||||
return false;
|
||||
|
||||
@@ -1310,10 +1318,27 @@ static bool kick_pool(struct worker_pool *pool)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
wake_up_process(p);
|
||||
*wakep = p;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* kick_pool - wake up an idle worker if necessary
|
||||
* @pool: pool to kick
|
||||
*
|
||||
* @pool may have pending work items. Wake up worker if necessary. Returns
|
||||
* whether a worker was woken up.
|
||||
*/
|
||||
static bool kick_pool(struct worker_pool *pool)
|
||||
{
|
||||
struct task_struct *p;
|
||||
bool kicked = kick_pool_pick(pool, &p);
|
||||
|
||||
if (p)
|
||||
wake_up_process(p);
|
||||
return kicked;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_WQ_CPU_INTENSIVE_REPORT
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user