[PATCH 4/4] Handle CPU_LOCK_ACQUIRE and CPU_LOCK_RELEASE in workqueue_cpu_callback.

Gautham R Shenoy
2006-11-14T12:24:26Z

In hot-cpu callback function workqueue_cpu_callback, lock the workqueue_mutex
under CPU_LOCK_ACQUIRE and release it under CPU_LOCK_RELEASE.

This eliminates handling of redundant events namely CPU_DOWN_PREPARE and
CPU_DOWN_FAILED.

Signed-off-by: Gautham R Shenoy <ego@in.ibm.com>

--
kernel/workqueue.c | 18 +++++++-----------
1 files changed, 7 insertions(+), 11 deletions(-)

Index: hotplug/kernel/workqueue.c
===================================================================
--- hotplug.orig/kernel/workqueue.c
+++ hotplug/kernel/workqueue.c
@@ -638,8 +638,11 @@ static int __devinit workqueue_cpu_callb
struct workqueue_struct *wq;

switch (action) {
- case CPU_UP_PREPARE:
+ case CPU_LOCK_ACQUIRE:
mutex_lock(&workqueue_mutex);
+ break;
+
+ case CPU_UP_PREPARE:
/* Create a new workqueue thread for it. */
list_for_each_entry(wq, &workqueues, list) {
if (!create_workqueue_thread(wq, hotcpu)) {
@@ -658,7 +661,6 @@ static int __devinit workqueue_cpu_callb
kthread_bind(cwq->thread, hotcpu);
wake_up_process(cwq->thread);
}
- mutex_unlock(&workqueue_mutex);
break;

case CPU_UP_CANCELED:
@@ -670,15 +672,6 @@ static int __devinit workqueue_cpu_callb
any_online_cpu(cpu_online_map));
cleanup_workqueue_thread(wq, hotcpu);
}
- mutex_unlock(&workqueue_mutex);
- break;
-
- case CPU_DOWN_PREPARE:
- mutex_lock(&workqueue_mutex);
- break;
-
- case CPU_DOWN_FAILED:
- mutex_unlock(&workqueue_mutex);
break;

case CPU_DEAD:
@@ -686,6 +679,9 @@ static int __devinit workqueue_cpu_callb
cleanup_workqueue_thread(wq, hotcpu);
list_for_each_entry(wq, &workqueues, list)
take_over_work(wq, hotcpu);
+ break;
+
+ case CPU_LOCK_RELEASE:
mutex_unlock(&workqueue_mutex);
break;