public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] speedup flush_workqueue for singlethread_workqueue
@ 2004-06-04 22:13 Anil
  2004-06-04 22:30 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Anil @ 2004-06-04 22:13 UTC (permalink / raw)
  To: linux-kernel, Andrew Morton

	In the flush_workqueue function for a single_threaded_worqueue case the code seemed to loop the same cpu_workqueue_struct
for each_online_cpu's. The attached patch checks this condition and bails out of for loop there by speeding up the flush_workqueue
for a singlethreaded_workqueue.

Please apply.

Thanks,
-anil

---

Name: speedup_flush_workqueue_for_single_thread
Status: Test Passed

 linux-2.6.7-rc2-mm2-root/kernel/workqueue.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff -puN kernel/workqueue.c~flush_work_queue_fix kernel/workqueue.c
--- linux-2.6.7-rc2-mm2/kernel/workqueue.c~flush_work_queue_fix	2004-06-04 21:38:49.848195790 -0700
+++ linux-2.6.7-rc2-mm2-root/kernel/workqueue.c	2004-06-04 21:42:50.013357817 -0700
@@ -236,6 +236,7 @@ void fastcall flush_workqueue(struct wor
 {
 	struct cpu_workqueue_struct *cwq;
 	int cpu;
+	int run_once = 0;
 
 	might_sleep();
 
@@ -244,9 +245,12 @@ void fastcall flush_workqueue(struct wor
 		DEFINE_WAIT(wait);
 		long sequence_needed;
 
-		if (is_single_threaded(wq))
+		if (is_single_threaded(wq)) {
+			if (run_once)
+				break;
 			cwq = wq->cpu_wq + 0; /* Always use cpu 0's area. */
-		else
+			run_once = 1;
+		} else
 			cwq = wq->cpu_wq + cpu;
 
 		if (cwq->thread == current) {

_





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-06-07 17:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-04 22:13 [PATCH] speedup flush_workqueue for singlethread_workqueue Anil
2004-06-04 22:30 ` Andrew Morton
2004-06-06  2:11   ` Rusty Russell
2004-06-07 17:46     ` Anil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox