From: Eric Dumazet <eric.dumazet@gmail.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
netdev <netdev@vger.kernel.org>,
David Miller <davem@davemloft.net>, Tejun Heo <tj@kernel.org>,
Rusty Russell <rusty@rustcorp.com.au>
Subject: Re: [PATCH] kthread: NUMA aware kthread_create_on_cpu()
Date: Sun, 28 Nov 2010 23:51:51 +0100 [thread overview]
Message-ID: <1290984712.29196.100.camel@edumazet-laptop> (raw)
In-Reply-To: <20101128224024.GA12300@basil.fritz.box>
Le dimanche 28 novembre 2010 à 23:40 +0100, Andi Kleen a écrit :
> On Sun, Nov 28, 2010 at 08:33:53PM +0100, Eric Dumazet wrote:
> > @@ -101,7 +103,15 @@ static int kthread(void *_create)
> > static void create_kthread(struct kthread_create_info *create)
> > {
> > int pid;
> > -
> > + static int last_cpu_pref = -1;
> > +
> > + if (create->cpu != last_cpu_pref) {
>
> Is that actually thread-safe?
Yes, we use one dedicated task to create all kthreads.
This task runs kthreadd(void *unused) in kernel/kthread.c
This only duty is to create tasks.
>
> > +void numa_cpubind_policy(int cpu)
> > +{
> > + nodemask_t mask;
> > +
> > + init_nodemask_of_node(&mask, cpu_to_node(cpu));
> > + do_set_mempolicy(MPOL_BIND, 0, &mask);
>
> You don't want bind, you want preferred, otherwise this
> will explode if the node is empty.
>
OK thanks, I'll test the patch with BIND or PREFERRED on x86_32 mode
since I have one machine with two sockets, 2GB on each socket, so 2nd
node only have HIGHMEM, no LOWMEM.
> Also this messes up the policy of the caller process. You really
> need to save/restore it.
Well, caller process duty is to create kthreads in a loop.
>
> And if the slab is configured for slab interleaving in
> the cpuset this will be ignored I think.
>
> Also I think the slab fast path ignores the policy anyways,
> the policy only acts when slab has to grab new pages.
> Are you sure this works at all?
>
It works on x86 at least, I tested this patch and got correct stacks for
pktgen and ksoftirqd kthreads for sure.
> It would be probably better to pass through the node
> to the low level allocation functions and use them
> there directly.
>
It would be difficult, because do_fork() is arch dependant
> Problem is that this ends up in architecture specific code
> for the stack, so may be a larger patch.
I suggest arches that need slab to allocate kthread stacks do the
appropriate changes, because I am not able to make them myself.
On x86, we use page allocator only, so NUMA mempolicy is used.
next prev parent reply other threads:[~2010-11-28 22:51 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-28 19:33 [PATCH] kthread: NUMA aware kthread_create_on_cpu() Eric Dumazet
2010-11-28 22:40 ` Andi Kleen
2010-11-28 22:51 ` Eric Dumazet [this message]
2010-11-28 23:01 ` Andi Kleen
2010-11-28 23:37 ` Eric Dumazet
2010-11-29 9:05 ` Andi Kleen
2010-11-29 9:38 ` Eric Dumazet
2010-11-29 15:13 ` [PATCH v2 0/4] " Eric Dumazet
2010-11-29 16:09 ` Andi Kleen
2010-11-29 17:39 ` David Miller
2010-11-29 17:59 ` Eric Dumazet
2010-11-29 23:31 ` Rusty Russell
2010-11-29 15:13 ` [PATCH v2 1/4] mm: NUMA aware alloc_task_struct_node() Eric Dumazet
2010-11-29 15:14 ` [PATCH v2 2/4] mm: NUMA aware alloc_thread_info_node() Eric Dumazet
2010-11-29 15:14 ` [PATCH v2 3/4] kthread: NUMA aware kthread_create_on_cpu() Eric Dumazet
2010-12-10 0:44 ` Andrew Morton
2010-12-10 5:59 ` Eric Dumazet
2010-12-10 6:32 ` Andrew Morton
2010-12-10 7:02 ` Eric Dumazet
2010-12-10 7:09 ` Andrew Morton
2010-12-13 6:26 ` Thomas Fjellstrom
2010-11-29 15:15 ` [PATCH v2 4/4] kthread: use kthread_create_on_cpu() Eric Dumazet
2010-11-29 15:19 ` Tejun Heo
2010-11-30 9:38 ` David Howells
2010-11-30 9:59 ` Eric Dumazet
2010-11-29 9:03 ` [PATCH] kthread: NUMA aware kthread_create_on_cpu() Américo Wang
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=1290984712.29196.100.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=tj@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox