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
1504}1504}
1505 1505
1506/**1506/**
1507 * worker_maybe_bind_and_lock - bind worker to its cpu if possible and lock pool1507 * worker_maybe_bind_and_lock - try to bind %current to worker_pool and lock it
1508 * @worker: self1508 * @pool: target worker_pool
1509 *
1510 * Bind %current to the cpu of @pool if it is associated and lock @pool.
1509 *1511 *
1510 * Works which are scheduled while the cpu is online must at least be1512 * Works which are scheduled while the cpu is online must at least be
1511 * scheduled to a worker which is bound to the cpu so that if they are1513 * 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
1533 * %true if the associated pool is online (@worker is successfully1535 * %true if the associated pool is online (@worker is successfully
1534 * bound), %false if offline.1536 * bound), %false if offline.
1535 */1537 */
1536static bool worker_maybe_bind_and_lock(struct worker *worker)1538static bool worker_maybe_bind_and_lock(struct worker_pool *pool)
1537__acquires(&pool->lock)1539__acquires(&pool->lock)
1538{1540{
1539 struct worker_pool *pool = worker->pool;
1540
1541 while (true) {1541 while (true) {
1542 /*1542 /*
1543 * The following call may fail, succeed or succeed1543 * The following call may fail, succeed or succeed
@@ -1575,7 +1575,7 @@ __acquires(&pool->lock) · 31 unmodified lines
1575static void idle_worker_rebind(struct worker *worker)1575static void idle_worker_rebind(struct worker *worker)
1576{1576{
1577 /* CPU may go down again inbetween, clear UNBOUND only on success */1577 /* 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))
1579 worker_clr_flags(worker, WORKER_UNBOUND);1579 worker_clr_flags(worker, WORKER_UNBOUND);
1580 1580
1581 /* rebind complete, become available again */1581 /* rebind complete, become available again */
@@ -1593,7 +1593,7 @@ static void busy_worker_rebind_fn(struct work_struct *work) · 11 unmodified lines
1593{1593{
1594 struct worker *worker = container_of(work, struct worker, rebind_work);1594 struct worker *worker = container_of(work, struct worker, rebind_work);
1595 1595
1596 if (worker_maybe_bind_and_lock(worker))1596 if (worker_maybe_bind_and_lock(worker->pool))
1597 worker_clr_flags(worker, WORKER_UNBOUND);1597 worker_clr_flags(worker, WORKER_UNBOUND);
1598 1598
1599 spin_unlock_irq(&worker->pool->lock);1599 spin_unlock_irq(&worker->pool->lock);
@@ -2038,7 +2038,7 @@ static bool manage_workers(struct worker *worker) · 438 unmodified lines
2038 * on @pool's current state. Try it and adjust2038 * on @pool's current state. Try it and adjust
2039 * %WORKER_UNBOUND accordingly.2039 * %WORKER_UNBOUND accordingly.
2040 */2040 */
2041 if (worker_maybe_bind_and_lock(worker))2041 if (worker_maybe_bind_and_lock(pool))
2042 worker->flags &= ~WORKER_UNBOUND;2042 worker->flags &= ~WORKER_UNBOUND;
2043 else2043 else
2044 worker->flags |= WORKER_UNBOUND;2044 worker->flags |= WORKER_UNBOUND;
@@ -2358,7 +2358,7 @@ repeat: · 313 unmodified lines
2358 2358
2359 /* migrate to the target cpu if possible */2359 /* migrate to the target cpu if possible */
2360 rescuer->pool = pool;2360 rescuer->pool = pool;
2361 worker_maybe_bind_and_lock(rescuer);2361 worker_maybe_bind_and_lock(pool);
2362 2362
2363 /*2363 /*
2364 * Slurp in all works issued via this workqueue and2364 * Slurp in all works issued via this workqueue and