* + kthread-numa-aware-kthread_create_on_cpu.patch added to -mm tree
@ 2010-12-10 0:44 akpm
2010-12-23 19:12 ` Peter Zijlstra
0 siblings, 1 reply; 11+ messages in thread
From: akpm @ 2010-12-10 0:44 UTC (permalink / raw)
To: mm-commits
Cc: eric.dumazet, ak, davem, dhowells, fenghua.yu, linux-arch, rusty,
tj, tony.luck
The patch titled
kthread: NUMA aware kthread_create_on_cpu()
has been added to the -mm tree. Its filename is
kthread-numa-aware-kthread_create_on_cpu.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/SubmitChecklist when testing your code ***
See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find
out what to do about this
The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/
------------------------------------------------------
Subject: kthread: NUMA aware kthread_create_on_cpu()
From: Eric Dumazet <eric.dumazet@gmail.com>
All kthreads being created from a single helper task, they all use memory
from a single node for their kernel stack and task struct.
This patch suite creates kthread_create_on_cpu(), adding a 'cpu' parameter
to parameters already used by kthread_create().
This parameter serves in allocating memory for the new kthread on its
memory node if possible.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Acked-by: David S. Miller <davem@davemloft.net>
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: Tejun Heo <tj@kernel.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: David Howells <dhowells@redhat.com>
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
include/linux/kthread.h | 14 ++++++++++----
include/linux/sched.h | 1 +
kernel/fork.c | 3 ++-
kernel/kthread.c | 32 ++++++++++++++++++++++++++------
4 files changed, 39 insertions(+), 11 deletions(-)
diff -puN include/linux/kthread.h~kthread-numa-aware-kthread_create_on_cpu include/linux/kthread.h
--- a/include/linux/kthread.h~kthread-numa-aware-kthread_create_on_cpu
+++ a/include/linux/kthread.h
@@ -4,10 +4,15 @@
#include <linux/err.h>
#include <linux/sched.h>
-struct task_struct *kthread_create(int (*threadfn)(void *data),
- void *data,
- const char namefmt[], ...)
- __attribute__((format(printf, 3, 4)));
+struct task_struct *kthread_create_on_cpu(int (*threadfn)(void *data),
+ void *data,
+ int cpu,
+ const char namefmt[], ...)
+ __attribute__((format(printf, 4, 5)));
+
+#define kthread_create(threadfn, data, namefmt, arg...) \
+ kthread_create_on_cpu(threadfn, data, -1, namefmt, ##arg)
+
/**
* kthread_run - create and wake a thread.
@@ -34,6 +39,7 @@ void *kthread_data(struct task_struct *k
int kthreadd(void *unused);
extern struct task_struct *kthreadd_task;
+extern int tsk_fork_get_node(struct task_struct *tsk);
/*
* Simple work processor based on kthread.
diff -puN include/linux/sched.h~kthread-numa-aware-kthread_create_on_cpu include/linux/sched.h
--- a/include/linux/sched.h~kthread-numa-aware-kthread_create_on_cpu
+++ a/include/linux/sched.h
@@ -1466,6 +1466,7 @@ struct task_struct {
#ifdef CONFIG_NUMA
struct mempolicy *mempolicy; /* Protected by alloc_lock */
short il_next;
+ short pref_node_fork;
#endif
atomic_t fs_excl; /* holding fs exclusive resources */
struct rcu_head rcu;
diff -puN kernel/fork.c~kthread-numa-aware-kthread_create_on_cpu kernel/fork.c
--- a/kernel/fork.c~kthread-numa-aware-kthread_create_on_cpu
+++ a/kernel/fork.c
@@ -66,6 +66,7 @@
#include <linux/posix-timers.h>
#include <linux/user-return-notifier.h>
#include <linux/oom.h>
+#include <linux/kthread.h>
#include <asm/pgtable.h>
#include <asm/pgalloc.h>
@@ -253,7 +254,7 @@ static struct task_struct *dup_task_stru
struct task_struct *tsk;
struct thread_info *ti;
unsigned long *stackend;
- int node = numa_node_id();
+ int node = tsk_fork_get_node(orig);
int err;
prepare_to_copy(orig);
diff -puN kernel/kthread.c~kthread-numa-aware-kthread_create_on_cpu kernel/kthread.c
--- a/kernel/kthread.c~kthread-numa-aware-kthread_create_on_cpu
+++ a/kernel/kthread.c
@@ -27,6 +27,7 @@ struct kthread_create_info
/* Information passed to kthread() from kthreadd. */
int (*threadfn)(void *data);
void *data;
+ int cpu;
/* Result passed back to kthread_create() from kthreadd. */
struct task_struct *result;
@@ -98,10 +99,24 @@ static int kthread(void *_create)
do_exit(ret);
}
+/* called from do_fork() to get node information for about to be created task */
+int tsk_fork_get_node(struct task_struct *tsk)
+{
+#ifdef CONFIG_NUMA
+ if (tsk == kthreadd_task)
+ return tsk->pref_node_fork;
+#endif
+ return numa_node_id();
+}
+
static void create_kthread(struct kthread_create_info *create)
{
int pid;
+#ifdef CONFIG_NUMA
+ current->pref_node_fork = (create->cpu != -1) ?
+ cpu_to_node(create->cpu) : -1;
+#endif
/* We want our own signal handler (we take no signals by default). */
pid = kernel_thread(kthread, create, CLONE_FS | CLONE_FILES | SIGCHLD);
if (pid < 0) {
@@ -111,15 +126,18 @@ static void create_kthread(struct kthrea
}
/**
- * kthread_create - create a kthread.
+ * kthread_create_on_cpu - create a kthread.
* @threadfn: the function to run until signal_pending(current).
* @data: data ptr for @threadfn.
+ * @cpu: cpu number.
* @namefmt: printf-style name for the thread.
*
* Description: This helper function creates and names a kernel
* thread. The thread will be stopped: use wake_up_process() to start
* it. See also kthread_run().
*
+ * If thread is going to be bound on a particular cpu, give its number
+ * in @cpu, to get NUMA affinity for kthread stack, or else give -1.
* When woken, the thread will run @threadfn() with @data as its
* argument. @threadfn() can either call do_exit() directly if it is a
* standalone thread for which noone will call kthread_stop(), or
@@ -129,15 +147,17 @@ static void create_kthread(struct kthrea
*
* Returns a task_struct or ERR_PTR(-ENOMEM).
*/
-struct task_struct *kthread_create(int (*threadfn)(void *data),
- void *data,
- const char namefmt[],
- ...)
+struct task_struct *kthread_create_on_cpu(int (*threadfn)(void *data),
+ void *data,
+ int cpu,
+ const char namefmt[],
+ ...)
{
struct kthread_create_info create;
create.threadfn = threadfn;
create.data = data;
+ create.cpu = cpu;
init_completion(&create.done);
spin_lock(&kthread_create_lock);
@@ -164,7 +184,7 @@ struct task_struct *kthread_create(int (
}
return create.result;
}
-EXPORT_SYMBOL(kthread_create);
+EXPORT_SYMBOL(kthread_create_on_cpu);
/**
* kthread_bind - bind a just-created kthread to a cpu.
_
Patches currently in -mm which might be from eric.dumazet@gmail.com are
origin.patch
linux-next.patch
irq-use-per_cpu-kstat_irqs.patch
timers-use-this_cpu_read.patch
mm-numa-aware-alloc_task_struct_node.patch
mm-numa-aware-alloc_thread_info_node.patch
kthread-numa-aware-kthread_create_on_cpu.patch
kthread-use-kthread_create_on_cpu.patch
include-asm-generic-vmlinuxldsh-make-readmostly-section-correctly-align.patch
percpu-add-new-macros-to-make-percpu-readmostly-section-correctly-align.patch
percpu-use-new-macros-for-x86-percpu-readmostly-section.patch
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: + kthread-numa-aware-kthread_create_on_cpu.patch added to -mm tree
2010-12-10 0:44 + kthread-numa-aware-kthread_create_on_cpu.patch added to -mm tree akpm
@ 2010-12-23 19:12 ` Peter Zijlstra
2010-12-23 21:45 ` Andrew Morton
2011-01-19 20:07 ` Andrew Morton
0 siblings, 2 replies; 11+ messages in thread
From: Peter Zijlstra @ 2010-12-23 19:12 UTC (permalink / raw)
To: akpm
Cc: mm-commits, eric.dumazet, ak, davem, dhowells, fenghua.yu,
linux-arch, rusty, tj, tony.luck
On Thu, 2010-12-09 at 16:44 -0800, akpm@linux-foundation.org wrote:
> +struct task_struct *kthread_create_on_cpu(int (*threadfn)(void *data),
> + void *data,
> + int cpu,
> + const char namefmt[],
> + ...)
I thought it was agreed that name sucked too much to live?
All other *_on_cpu() interfaces actually do stuff on that cpu, but this
does not in fact create a cpu affine task.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: + kthread-numa-aware-kthread_create_on_cpu.patch added to -mm tree
2010-12-23 19:12 ` Peter Zijlstra
@ 2010-12-23 21:45 ` Andrew Morton
2011-01-19 20:07 ` Andrew Morton
1 sibling, 0 replies; 11+ messages in thread
From: Andrew Morton @ 2010-12-23 21:45 UTC (permalink / raw)
To: Peter Zijlstra
Cc: eric.dumazet, ak, davem, dhowells, fenghua.yu, linux-arch, rusty,
tj, tony.luck
On Thu, 23 Dec 2010 20:12:02 +0100 Peter Zijlstra <peterz@infradead.org> wrote:
> On Thu, 2010-12-09 at 16:44 -0800, akpm@linux-foundation.org wrote:
> > +struct task_struct *kthread_create_on_cpu(int (*threadfn)(void *data),
> > + void *data,
> > + int cpu,
> > + const char namefmt[],
> > + ...)
>
> I thought it was agreed that name sucked too much to live?
>
> All other *_on_cpu() interfaces actually do stuff on that cpu, but this
> does not in fact create a cpu affine task.
Agree. I'd assumed that a new version was brewing in Dumazet Labs.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: + kthread-numa-aware-kthread_create_on_cpu.patch added to -mm tree
2010-12-23 19:12 ` Peter Zijlstra
2010-12-23 21:45 ` Andrew Morton
@ 2011-01-19 20:07 ` Andrew Morton
2011-01-19 20:15 ` Eric Dumazet
1 sibling, 1 reply; 11+ messages in thread
From: Andrew Morton @ 2011-01-19 20:07 UTC (permalink / raw)
To: Peter Zijlstra
Cc: eric.dumazet, ak, davem, dhowells, fenghua.yu, linux-arch, rusty,
tj, tony.luck
On Thu, 23 Dec 2010 20:12:02 +0100
Peter Zijlstra <peterz@infradead.org> wrote:
> On Thu, 2010-12-09 at 16:44 -0800, akpm@linux-foundation.org wrote:
> > +struct task_struct *kthread_create_on_cpu(int (*threadfn)(void *data),
> > + void *data,
> > + int cpu,
> > + const char namefmt[],
> > + ...)
>
> I thought it was agreed that name sucked too much to live?
I agreed ;)
> All other *_on_cpu() interfaces actually do stuff on that cpu, but this
> does not in fact create a cpu affine task.
The patches are stuck in my tree awaiting some movement here..
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: + kthread-numa-aware-kthread_create_on_cpu.patch added to -mm tree
2011-01-19 20:07 ` Andrew Morton
@ 2011-01-19 20:15 ` Eric Dumazet
2011-01-19 20:17 ` Andi Kleen
0 siblings, 1 reply; 11+ messages in thread
From: Eric Dumazet @ 2011-01-19 20:15 UTC (permalink / raw)
To: Andrew Morton
Cc: Peter Zijlstra, ak, davem, dhowells, fenghua.yu, linux-arch,
rusty, tj, tony.luck
Le mercredi 19 janvier 2011 à 12:07 -0800, Andrew Morton a écrit :
> On Thu, 23 Dec 2010 20:12:02 +0100
> Peter Zijlstra <peterz@infradead.org> wrote:
>
> > On Thu, 2010-12-09 at 16:44 -0800, akpm@linux-foundation.org wrote:
> > > +struct task_struct *kthread_create_on_cpu(int (*threadfn)(void *data),
> > > + void *data,
> > > + int cpu,
> > > + const char namefmt[],
> > > + ...)
> >
> > I thought it was agreed that name sucked too much to live?
>
> I agreed ;)
>
> > All other *_on_cpu() interfaces actually do stuff on that cpu, but this
> > does not in fact create a cpu affine task.
>
> The patches are stuck in my tree awaiting some movement here..
Oh well.
I wont discuss about a function _name_ Andrew.
If nobody can chose one better than the one I chosed, what can I do ?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: + kthread-numa-aware-kthread_create_on_cpu.patch added to -mm tree
2011-01-19 20:15 ` Eric Dumazet
@ 2011-01-19 20:17 ` Andi Kleen
2011-01-19 20:21 ` Eric Dumazet
0 siblings, 1 reply; 11+ messages in thread
From: Andi Kleen @ 2011-01-19 20:17 UTC (permalink / raw)
To: Eric Dumazet
Cc: Andrew Morton, Peter Zijlstra, davem, dhowells, fenghua.yu,
linux-arch, rusty, tj, tony.luck
>
> I wont discuss about a function _name_ Andrew.
>
> If nobody can chose one better than the one I chosed, what can I do ?
kthread_create_node() would seem logical (with a node parameter)
-Andi
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: + kthread-numa-aware-kthread_create_on_cpu.patch added to -mm tree
2011-01-19 20:17 ` Andi Kleen
@ 2011-01-19 20:21 ` Eric Dumazet
2011-01-19 20:44 ` Andrew Morton
0 siblings, 1 reply; 11+ messages in thread
From: Eric Dumazet @ 2011-01-19 20:21 UTC (permalink / raw)
To: Andi Kleen
Cc: Andrew Morton, Peter Zijlstra, davem, dhowells, fenghua.yu,
linux-arch, rusty, tj, tony.luck
Le mercredi 19 janvier 2011 à 12:17 -0800, Andi Kleen a écrit :
> >
> > I wont discuss about a function _name_ Andrew.
> >
> > If nobody can chose one better than the one I chosed, what can I do ?
>
> kthread_create_node() would seem logical (with a node parameter)
>
> -Andi
I already explained why I dont like this suggestion.
1) My plan was to later add cpu affinity.
2) All users I converted want to create one kthread per cpu, not per
node.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: + kthread-numa-aware-kthread_create_on_cpu.patch added to -mm tree
2011-01-19 20:21 ` Eric Dumazet
@ 2011-01-19 20:44 ` Andrew Morton
2011-01-19 20:50 ` Eric Dumazet
0 siblings, 1 reply; 11+ messages in thread
From: Andrew Morton @ 2011-01-19 20:44 UTC (permalink / raw)
To: Eric Dumazet
Cc: Andi Kleen, Peter Zijlstra, davem, dhowells, fenghua.yu,
linux-arch, rusty, tj, tony.luck
On Wed, 19 Jan 2011 21:21:55 +0100
Eric Dumazet <eric.dumazet@gmail.com> wrote:
> Le mercredi 19 janvier 2011 __ 12:17 -0800, Andi Kleen a __crit :
> > >
> > > I wont discuss about a function _name_ Andrew.
> > >
> > > If nobody can chose one better than the one I chosed, what can I do ?
> >
> > kthread_create_node() would seem logical (with a node parameter)
> >
> > -Andi
>
> I already explained why I dont like this suggestion.
>
> 1) My plan was to later add cpu affinity.
That would be called kthread_create_on_cpu() except whoops, this patch
already took that.
> 2) All users I converted want to create one kthread per cpu, not per
> node.
kswapd is a potential user. It would want one kthread per node.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: + kthread-numa-aware-kthread_create_on_cpu.patch added to -mm tree
2011-01-19 20:44 ` Andrew Morton
@ 2011-01-19 20:50 ` Eric Dumazet
2011-01-19 20:59 ` Andrew Morton
0 siblings, 1 reply; 11+ messages in thread
From: Eric Dumazet @ 2011-01-19 20:50 UTC (permalink / raw)
To: Andrew Morton
Cc: Andi Kleen, Peter Zijlstra, davem, dhowells, fenghua.yu,
linux-arch, rusty, tj, tony.luck
Le mercredi 19 janvier 2011 à 12:44 -0800, Andrew Morton a écrit :
> On Wed, 19 Jan 2011 21:21:55 +0100
> Eric Dumazet <eric.dumazet@gmail.com> wrote:
>
> > Le mercredi 19 janvier 2011 __ 12:17 -0800, Andi Kleen a __crit :
> > > >
> > > > I wont discuss about a function _name_ Andrew.
> > > >
> > > > If nobody can chose one better than the one I chosed, what can I do ?
> > >
> > > kthread_create_node() would seem logical (with a node parameter)
> > >
> > > -Andi
> >
> > I already explained why I dont like this suggestion.
> >
> > 1) My plan was to later add cpu affinity.
>
> That would be called kthread_create_on_cpu() except whoops, this patch
> already took that.
>
I surrender :)
I'll send a patch, or do you prefer I respin the 4 patches ?
> > 2) All users I converted want to create one kthread per cpu, not per
> > node.
>
> kswapd is a potential user. It would want one kthread per node.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: + kthread-numa-aware-kthread_create_on_cpu.patch added to -mm tree
2011-01-19 20:50 ` Eric Dumazet
@ 2011-01-19 20:59 ` Andrew Morton
2011-01-19 21:10 ` Eric Dumazet
0 siblings, 1 reply; 11+ messages in thread
From: Andrew Morton @ 2011-01-19 20:59 UTC (permalink / raw)
To: Eric Dumazet
Cc: Andi Kleen, Peter Zijlstra, davem, dhowells, fenghua.yu,
linux-arch, rusty, tj, tony.luck
On Wed, 19 Jan 2011 21:50:47 +0100
Eric Dumazet <eric.dumazet@gmail.com> wrote:
> Le mercredi 19 janvier 2011 __ 12:44 -0800, Andrew Morton a __crit :
> > On Wed, 19 Jan 2011 21:21:55 +0100
> > Eric Dumazet <eric.dumazet@gmail.com> wrote:
> >
> > > Le mercredi 19 janvier 2011 __ 12:17 -0800, Andi Kleen a __crit :
> > > > >
> > > > > I wont discuss about a function _name_ Andrew.
> > > > >
> > > > > If nobody can chose one better than the one I chosed, what can I do ?
> > > >
> > > > kthread_create_node() would seem logical (with a node parameter)
> > > >
> > > > -Andi
> > >
> > > I already explained why I dont like this suggestion.
> > >
> > > 1) My plan was to later add cpu affinity.
> >
> > That would be called kthread_create_on_cpu() except whoops, this patch
> > already took that.
> >
>
> I surrender :)
Does that mean we have a name ;)
> I'll send a patch, or do you prefer I respin the 4 patches ?
I can trivially edit the patches locally if it's just a rename.
kthread_create_for_cpu() would do the trick, I suggest.
If we decide on kthread_create_node(node_t) then that's a significant
rework.
I'm all worn out too and would be OK with either approach.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: + kthread-numa-aware-kthread_create_on_cpu.patch added to -mm tree
2011-01-19 20:59 ` Andrew Morton
@ 2011-01-19 21:10 ` Eric Dumazet
0 siblings, 0 replies; 11+ messages in thread
From: Eric Dumazet @ 2011-01-19 21:10 UTC (permalink / raw)
To: Andrew Morton
Cc: Andi Kleen, Peter Zijlstra, davem, dhowells, fenghua.yu,
linux-arch, rusty, tj, tony.luck
Le mercredi 19 janvier 2011 à 12:59 -0800, Andrew Morton a écrit :
> On Wed, 19 Jan 2011 21:50:47 +0100
> Eric Dumazet <eric.dumazet@gmail.com> wrote:
> > I surrender :)
>
> Does that mean we have a name ;)
>
> > I'll send a patch, or do you prefer I respin the 4 patches ?
>
> I can trivially edit the patches locally if it's just a rename.
> kthread_create_for_cpu() would do the trick, I suggest.
>
> If we decide on kthread_create_node(node_t) then that's a significant
> rework.
>
> I'm all worn out too and would be OK with either approach.
Well, I was just changing to kthread_create_on_node(), since it appears
one call site doesnt want the kthread_bind(p, cpu);
(kernel/workqueue.c :
if (bind && !on_unbound_cpu)
kthread_bind(worker->task, gcwq->cpu);
So my idea of doing the kthread_bind() inside kthread_create_on_cpu() is
not possible
Something like following patch on top of previous ones :
[PATCH] kthread: rename kthread_create_on_cpu()
People told me kthread_create_on_cpu() was a wrong name and prefer
kthread_create_on_node()
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: David Miller <davem@davemloft.net>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Tejun Heo <tj@kernel.org>
Cc: linux-arch@vger.kernel.org
---
include/linux/kthread.h | 10 +++++-----
kernel/kthread.c | 27 +++++++++++++--------------
kernel/softirq.c | 6 ++++--
kernel/stop_machine.c | 6 ++++--
kernel/workqueue.c | 6 ++++--
net/core/pktgen.c | 6 ++++--
6 files changed, 34 insertions(+), 27 deletions(-)
diff --git a/include/linux/kthread.h b/include/linux/kthread.h
index ec54c17..6ec201d 100644
--- a/include/linux/kthread.h
+++ b/include/linux/kthread.h
@@ -4,14 +4,14 @@
#include <linux/err.h>
#include <linux/sched.h>
-struct task_struct *kthread_create_on_cpu(int (*threadfn)(void *data),
- void *data,
- int cpu,
- const char namefmt[], ...)
+struct task_struct *kthread_create_on_node(int (*threadfn)(void *data),
+ void *data,
+ int node,
+ const char namefmt[], ...)
__attribute__((format(printf, 4, 5)));
#define kthread_create(threadfn, data, namefmt, arg...) \
- kthread_create_on_cpu(threadfn, data, -1, namefmt, ##arg)
+ kthread_create_on_node(threadfn, data, -1, namefmt, ##arg)
/**
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 1819927..684ab3f 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -27,7 +27,7 @@ struct kthread_create_info
/* Information passed to kthread() from kthreadd. */
int (*threadfn)(void *data);
void *data;
- int cpu;
+ int node;
/* Result passed back to kthread_create() from kthreadd. */
struct task_struct *result;
@@ -114,8 +114,7 @@ static void create_kthread(struct kthread_create_info *create)
int pid;
#ifdef CONFIG_NUMA
- current->pref_node_fork = (create->cpu != -1) ?
- cpu_to_node(create->cpu) : -1;
+ current->pref_node_fork = create->node;
#endif
/* We want our own signal handler (we take no signals by default). */
pid = kernel_thread(kthread, create, CLONE_FS | CLONE_FILES | SIGCHLD);
@@ -126,18 +125,18 @@ static void create_kthread(struct kthread_create_info *create)
}
/**
- * kthread_create_on_cpu - create a kthread.
+ * kthread_create_on_node - create a kthread.
* @threadfn: the function to run until signal_pending(current).
* @data: data ptr for @threadfn.
- * @cpu: cpu number.
+ * @node: memory node number.
* @namefmt: printf-style name for the thread.
*
* Description: This helper function creates and names a kernel
* thread. The thread will be stopped: use wake_up_process() to start
* it. See also kthread_run().
*
- * If thread is going to be bound on a particular cpu, give its number
- * in @cpu, to get NUMA affinity for kthread stack, or else give -1.
+ * If thread is going to be bound on a particular cpu, give its node
+ * in @node, to get NUMA affinity for kthread stack, or else give -1.
* When woken, the thread will run @threadfn() with @data as its
* argument. @threadfn() can either call do_exit() directly if it is a
* standalone thread for which noone will call kthread_stop(), or
@@ -147,17 +146,17 @@ static void create_kthread(struct kthread_create_info *create)
*
* Returns a task_struct or ERR_PTR(-ENOMEM).
*/
-struct task_struct *kthread_create_on_cpu(int (*threadfn)(void *data),
- void *data,
- int cpu,
- const char namefmt[],
- ...)
+struct task_struct *kthread_create_on_node(int (*threadfn)(void *data),
+ void *data,
+ int node,
+ const char namefmt[],
+ ...)
{
struct kthread_create_info create;
create.threadfn = threadfn;
create.data = data;
- create.cpu = cpu;
+ create.node = node;
init_completion(&create.done);
spin_lock(&kthread_create_lock);
@@ -184,7 +183,7 @@ struct task_struct *kthread_create_on_cpu(int (*threadfn)(void *data),
}
return create.result;
}
-EXPORT_SYMBOL(kthread_create_on_cpu);
+EXPORT_SYMBOL(kthread_create_on_node);
/**
* kthread_bind - bind a just-created kthread to a cpu.
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 118c666..fec6796 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -831,8 +831,10 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
switch (action) {
case CPU_UP_PREPARE:
case CPU_UP_PREPARE_FROZEN:
- p = kthread_create_on_cpu(run_ksoftirqd, hcpu, hotcpu,
- "ksoftirqd/%d", hotcpu);
+ p = kthread_create_on_node(run_ksoftirqd,
+ hcpu,
+ cpu_to_node(hotcpu),
+ "ksoftirqd/%d", hotcpu);
if (IS_ERR(p)) {
printk("ksoftirqd for %i failed\n", hotcpu);
return notifier_from_errno(PTR_ERR(p));
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index 7c0f287..e3516b2 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -301,8 +301,10 @@ static int __cpuinit cpu_stop_cpu_callback(struct notifier_block *nfb,
case CPU_UP_PREPARE:
BUG_ON(stopper->thread || stopper->enabled ||
!list_empty(&stopper->works));
- p = kthread_create_on_cpu(cpu_stopper_thread, stopper, cpu,
- "migration/%d", cpu);
+ p = kthread_create_on_node(cpu_stopper_thread,
+ stopper,
+ cpu_to_node(cpu),
+ "migration/%d", cpu);
if (IS_ERR(p))
return notifier_from_errno(PTR_ERR(p));
get_task_struct(p);
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 2aa2d32..3ff90e5 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1352,8 +1352,10 @@ static struct worker *create_worker(struct global_cwq *gcwq, bool bind)
worker->id = id;
if (!on_unbound_cpu)
- worker->task = kthread_create_on_cpu(worker_thread, worker, gcwq->cpu,
- "kworker/%u:%d", gcwq->cpu, id);
+ worker->task = kthread_create_on_node(worker_thread,
+ worker,
+ cpu_to_node(gcwq->cpu),
+ "kworker/%u:%d", gcwq->cpu, id);
else
worker->task = kthread_create(worker_thread, worker,
"kworker/u:%d", id);
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index e522e90..1f9d2e0 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -3812,8 +3812,10 @@ static int __init pktgen_create_thread(int cpu)
list_add_tail(&t->th_list, &pktgen_threads);
init_completion(&t->start_done);
- p = kthread_create_on_cpu(pktgen_thread_worker, t, cpu,
- "kpktgend_%d", cpu);
+ p = kthread_create_on_node(pktgen_thread_worker,
+ t,
+ cpu_to_node(cpu),
+ "kpktgend_%d", cpu);
if (IS_ERR(p)) {
pr_err("kernel_thread() failed for cpu %d\n", t->cpu);
list_del(&t->th_list);
^ permalink raw reply related [flat|nested] 11+ messages in thread
end of thread, other threads:[~2011-01-19 21:10 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-10 0:44 + kthread-numa-aware-kthread_create_on_cpu.patch added to -mm tree akpm
2010-12-23 19:12 ` Peter Zijlstra
2010-12-23 21:45 ` Andrew Morton
2011-01-19 20:07 ` Andrew Morton
2011-01-19 20:15 ` Eric Dumazet
2011-01-19 20:17 ` Andi Kleen
2011-01-19 20:21 ` Eric Dumazet
2011-01-19 20:44 ` Andrew Morton
2011-01-19 20:50 ` Eric Dumazet
2011-01-19 20:59 ` Andrew Morton
2011-01-19 21:10 ` Eric Dumazet
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.