struct worker *worker = NULL;
int id = -1;
+ lockdep_assert_held(&pool->manager_mutex);
+
spin_lock_irq(&pool->lock);
while (ida_get_new(&pool->worker_ida, &id)) {
spin_unlock_irq(&pool->lock);
* create_and_start_worker - create and start a worker for a pool
* @pool: the target pool
*
- * Create and start a new worker for @pool.
+ * Grab the managership of @pool and create and start a new worker for it.
*/
static int create_and_start_worker(struct worker_pool *pool)
{
struct worker *worker;
+ mutex_lock(&pool->manager_mutex);
+
worker = create_worker(pool);
if (worker) {
spin_lock_irq(&pool->lock);
spin_unlock_irq(&pool->lock);
}
+ mutex_unlock(&pool->manager_mutex);
+
return worker ? 0 : -ENOMEM;
}
struct worker_pool *pool = worker->pool;
int id = worker->id;
+ lockdep_assert_held(&pool->manager_mutex);
+ lockdep_assert_held(&pool->lock);
+
/* sanity check frenzy */
if (WARN_ON(worker->current_work) ||
WARN_ON(!list_empty(&worker->scheduled)))
* manager_mutex.
*/
mutex_lock(&pool->manager_arb);
+ mutex_lock(&pool->manager_mutex);
spin_lock_irq(&pool->lock);
while ((worker = first_worker(pool)))
WARN_ON(pool->nr_workers || pool->nr_idle);
spin_unlock_irq(&pool->lock);
+ mutex_unlock(&pool->manager_mutex);
mutex_unlock(&pool->manager_arb);
/* shut down the timers */