[PATCH] speedup flush_workqueue for singlethread_workqueue

Anil
2004-06-04T22:13:46Z

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) {

_