From: Oleg Nesterov <oleg@redhat.com>
To: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] workqueue: don't alloc_percpu for single workqueue
Date: Thu, 22 Jan 2009 17:11:32 +0100 [thread overview]
Message-ID: <20090122161132.GA27250@redhat.com> (raw)
In-Reply-To: <4977EB1C.4030405@cn.fujitsu.com>
On 01/22, Lai Jiangshan wrote:
>
> Oleg Nesterov wrote:
> > On 01/21, Lai Jiangshan wrote:
> >> @@ -906,6 +907,13 @@ void destroy_workqueue(struct workqueue_struct *wq)
> >> const struct cpumask *cpu_map = wq_cpu_map(wq);
> >> int cpu;
> >>
> >> + if (is_wq_single_threaded(wq)) {
> >> + cleanup_workqueue_thread(wq->cpu_wq);
> >> + kfree(wq->cpu_wq);
> >> + kfree(wq);
> >> + return;
> >> + }
> >
> > again, not sure I understand why this change is needed. Afaics we
> > only need to use kfree(wq->cpu_wq) instead of free_percpu() if
> > it is single-threaded.
> >
>
> I think this change is needed.
> In the single thread case, we don't need
> 1) cpu_maps_update_begin(). --> require cpu_add_remove_lock
> 2) remove workqueue from the list. (we did not inserted it)
>
> It is indeed that there is no bad result occurred when we do these
> things for single thread. But I think the destroying should not
> do things more than the creating.
I disagree.
Firstly, this path is rare and not time critical, it is better
to save a couple of bytes from .text.
But mostly I dislike the fact that we add another special case
for the single-threaded wqs which is not strictly needed.
Following your logic we can also change flush_workqueue(), it
doesn't need for_each_cpu_mask_nr() when single-threaded.
That said, I agree this is a matter of taste, I won't persist.
Oleg.
next prev parent reply other threads:[~2009-01-22 16:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-21 9:42 [PATCH] workqueue: don't alloc_percpu for single workqueue Lai Jiangshan
2009-01-21 10:29 ` Frédéric Weisbecker
2009-01-21 10:48 ` Ingo Molnar
2009-01-22 1:05 ` Lai Jiangshan
2009-01-21 12:17 ` Oleg Nesterov
2009-01-22 3:42 ` Lai Jiangshan
2009-01-22 16:11 ` Oleg Nesterov [this message]
2009-02-16 2:39 ` Lai Jiangshan
2009-01-21 13:01 ` Eric Dumazet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090122161132.GA27250@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.