History

workqueue: change argument of worker_maybe_bind_and_lock() to @pool

worker_maybe_bind_and_lock() currently takes @worker but only cares about @worker->pool. This patch updates worker_maybe_bind_and_lock() to take @pool instead of @worker. This will be used to better define synchronization rules regarding rescuer->pool updates. This doesn't introduce any functional change. tj: Updated the comments and description.

Lai Jiangshan committed 13 years ago

Commit f36dc671 parent f5faa071 file · +9 −9Browse files

Showing the changes to kernel/workqueue.c (1 of 1 file). Show all

Unified · Split

kernel/workqueue.c+9−9
@@ -1504,8 +1504,10 @@ static void worker_leave_idle(struct worker *worker) · 1503 unmodified lines
15041504 }
15051505
15061506 /**
1507− * worker_maybe_bind_and_lock - bind worker to its cpu if possible and lock pool
1508− * @worker: self
1507+ * worker_maybe_bind_and_lock - try to bind %current to worker_pool and lock it
1508+ * @pool: target worker_pool
1509+ *
1510+ * Bind %current to the cpu of @pool if it is associated and lock @pool.
15091511 *
15101512 * Works which are scheduled while the cpu is online must at least be
15111513 * scheduled to a worker which is bound to the cpu so that if they are
@@ -1533,11 +1535,9 @@ static void worker_leave_idle(struct worker *worker) · 21 unmodified lines
15331535 * %true if the associated pool is online (@worker is successfully
15341536 * bound), %false if offline.
15351537 */
1536−static bool worker_maybe_bind_and_lock(struct worker *worker)
1538+static bool worker_maybe_bind_and_lock(struct worker_pool *pool)
15371539 __acquires(&pool->lock)
15381540 {
1539− struct worker_pool *pool = worker->pool;
1540−
15411541 while (true) {
15421542 /*
15431543 * The following call may fail, succeed or succeed
@@ -1575,7 +1575,7 @@ __acquires(&pool->lock) · 31 unmodified lines
15751575 static void idle_worker_rebind(struct worker *worker)
15761576 {
15771577 /* CPU may go down again inbetween, clear UNBOUND only on success */
1578− if (worker_maybe_bind_and_lock(worker))
1578+ if (worker_maybe_bind_and_lock(worker->pool))
15791579 worker_clr_flags(worker, WORKER_UNBOUND);
15801580
15811581 /* rebind complete, become available again */
@@ -1593,7 +1593,7 @@ static void busy_worker_rebind_fn(struct work_struct *work) · 11 unmodified lines
15931593 {
15941594 struct worker *worker = container_of(work, struct worker, rebind_work);
15951595
1596− if (worker_maybe_bind_and_lock(worker))
1596+ if (worker_maybe_bind_and_lock(worker->pool))
15971597 worker_clr_flags(worker, WORKER_UNBOUND);
15981598
15991599 spin_unlock_irq(&worker->pool->lock);
@@ -2038,7 +2038,7 @@ static bool manage_workers(struct worker *worker) · 438 unmodified lines
20382038 * on @pool's current state. Try it and adjust
20392039 * %WORKER_UNBOUND accordingly.
20402040 */
2041− if (worker_maybe_bind_and_lock(worker))
2041+ if (worker_maybe_bind_and_lock(pool))
20422042 worker->flags &= ~WORKER_UNBOUND;
20432043 else
20442044 worker->flags |= WORKER_UNBOUND;
@@ -2358,7 +2358,7 @@ repeat: · 313 unmodified lines
23582358
23592359 /* migrate to the target cpu if possible */
23602360 rescuer->pool = pool;
2361− worker_maybe_bind_and_lock(rescuer);
2361+ worker_maybe_bind_and_lock(pool);
23622362
23632363 /*
23642364 * Slurp in all works issued via this workqueue and