From: Eric Dumazet <eric.dumazet@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Andi Kleen <ak@linux.intel.com>,
Peter Zijlstra <peterz@infradead.org>,
davem@davemloft.net, dhowells@redhat.com, fenghua.yu@intel.com,
linux-arch@vger.kernel.org, rusty@rustcorp.com.au, tj@kernel.org,
tony.luck@intel.com
Subject: Re: + kthread-numa-aware-kthread_create_on_cpu.patch added to -mm tree
Date: Wed, 19 Jan 2011 22:10:44 +0100 [thread overview]
Message-ID: <1295471444.2653.16.camel@edumazet-laptop> (raw)
In-Reply-To: <20110119125938.f6c9537a.akpm@linux-foundation.org>
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);
prev parent reply other threads:[~2011-01-19 21:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-10 0:44 + kthread-numa-aware-kthread_create_on_cpu.patch added to -mm tree akpm
2010-12-10 0:44 ` 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 message]
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=1295471444.2653.16.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=fenghua.yu@intel.com \
--cc=linux-arch@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rusty@rustcorp.com.au \
--cc=tj@kernel.org \
--cc=tony.luck@intel.com \
/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