Skip to contentSkip to conversation

workqueue: fix schedule_on_each_cpu()

PATCH New Ingo Molnar 1 participant 1 message Dec 18, 2006 Workqueue

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 workqueue: fix schedule_on_each_cpu()

From: Ingo Molnar <[email protected]>
Subject: [patch] workqueue: fix schedule_on_each_cpu()

fix the schedule_on_each_cpu() implementation: __queue_work() is now stricter, hence set the work-pending bit before passing in the new work.

(found in the -rt tree, using Peter Zijlstra's files-lock scalability patchset)

---
 kernel/workqueue.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
kernel/workqueue.c +5 -3
Index: linux/kernel/workqueue.c
===================================================================
@@ -637,9 +637,11 @@ int schedule_on_each_cpu(work_func_t fun
 
 	mutex_lock(&workqueue_mutex);
 	for_each_online_cpu(cpu) {
-		INIT_WORK(per_cpu_ptr(works, cpu), func);
-		__queue_work(per_cpu_ptr(keventd_wq->cpu_wq, cpu),
-				per_cpu_ptr(works, cpu));
+		struct work_struct *work = per_cpu_ptr(works, cpu);
+
+		INIT_WORK(work, func);
+		set_bit(WORK_STRUCT_PENDING, work_data_bits(work));
+		__queue_work(per_cpu_ptr(keventd_wq->cpu_wq, cpu), work);
 	}
 	mutex_unlock(&workqueue_mutex);
 	flush_workqueue(keventd_wq);