RE: [PATCH] speedup flush_workqueue for singlethread_workqueue

Anil
2004-06-07T17:50:29Z

Hi Andrew,
In the flush_workqueue, can we move lock_cpu_hotplug()/unlock_cpu_hotplug only for _non_single_threaded_ case as shown below
as these locks are not required for single_threaded_workqueue.

Thanks,
Anil

The attached patch applies on top of your changes.
Signed-off-by: Anil Keshavamurthy <anil.s.keshavamurthy@intel.com>
---

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

diff -puN kernel/workqueue.c~andrew2 kernel/workqueue.c
--- linux-2.6.7-rc2-mm2/kernel/workqueue.c~andrew2 2004-06-07 18:45:20.332139681 -0700
+++ linux-2.6.7-rc2-mm2-root/kernel/workqueue.c 2004-06-07 18:46:09.560680511 -0700
@@ -262,7 +262,6 @@ static void flush_cpu_workqueue(struct c
void fastcall flush_workqueue(struct workqueue_struct *wq)
{
might_sleep();
- lock_cpu_hotplug();

if (is_single_threaded(wq)) {
/* Always use cpu 0's area. */
@@ -270,11 +269,12 @@ void fastcall flush_workqueue(struct wor
} else {
int cpu;

+ lock_cpu_hotplug();
for_each_online_cpu(cpu)
flush_cpu_workqueue(wq->cpu_wq + cpu);
+ unlock_cpu_hotplug();
}

- unlock_cpu_hotplug();
}

static struct task_struct *create_workqueue_thread(struct workqueue_struct *wq,

_

>-----Original Message-----
>From: Rusty Russell [mailto:rusty@rustcorp.com.au]
>Sent: Saturday, June 05, 2004 7:11 PM
>To: Andrew Morton
>Cc: Keshavamurthy, Anil S; lkml - Kernel Mailing List
>Subject: Re: [PATCH] speedup flush_workqueue for singlethread_workqueue
>
>On Sat, 2004-06-05 at 08:30, Andrew Morton wrote:
>> "Anil" <anil.s.keshavamurthy@intel.com> wrote:
>> >
>> > 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.
>>
>>
>> OK, thanks. I think it's a bit clearer to do it as below.
>I haven't
>> tested it though.
>
>Me neither, but agree.
>
>Rusty.
>--
>Anyone who quotes me in their signature is an idiot -- Rusty Russell
>
>
>