lkml.org 
[lkml]   [2012]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 07/11 V5] workqueue: rebind manager
Date
Because the %UNBOUND bit of manager can't be cleared while it
is manage workers. maybe_rebind_manager() will be noticed and
will do rebind when needed.

It just prepares, this code is useless until
"we unbind/rebind without manager_mutex"

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
kernel/workqueue.c | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 9f4dd20..e9fc065 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1540,6 +1540,14 @@ static void worker_leave_idle(struct worker *worker)
list_del_init(&worker->entry);
}

+/* Does this worker need to be rebound */
+static bool need_to_rebind_worker(struct worker *worker)
+{
+ bool assoc = !(worker->pool->gcwq->flags & GCWQ_DISASSOCIATED);
+
+ return assoc && (worker->flags & WORKER_UNBOUND);
+}
+
/**
* worker_maybe_bind_and_lock - bind worker to its cpu if possible and lock gcwq
* @worker: self
@@ -2028,6 +2036,20 @@ static bool maybe_destroy_workers(struct worker_pool *pool)
return ret;
}

+static bool maybe_rebind_manager(struct worker *manager)
+{
+ if (unlikely(need_to_rebind_worker(manager))) {
+ spin_unlock_irq(&manager->pool->gcwq->lock);
+
+ if (worker_maybe_bind_and_lock(manager))
+ worker_clr_flags(manager, WORKER_UNBOUND);
+
+ return true;
+ }
+
+ return false;
+}
+
/**
* manage_workers - manage worker pool
* @worker: self
@@ -2065,6 +2087,7 @@ static bool manage_workers(struct worker *worker)
*/
ret |= maybe_destroy_workers(pool);
ret |= maybe_create_worker(pool);
+ ret |= maybe_rebind_manager(worker);

mutex_unlock(&pool->manager_mutex);
pool->manager = NULL;
--
1.7.4.4


\
 
 \ /
  Last update: 2012-09-05 13:04    [W:0.179 / U:1.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site