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@xxxxxxxxx> 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@xxxxxxxxx> Cc: David Miller <davem@xxxxxxxxxxxxx> Cc: Andi Kleen <andi@xxxxxxxxxxxxxx> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Cc: Rusty Russell <rusty@xxxxxxxxxxxxxxx> Cc: Tejun Heo <tj@xxxxxxxxxx> Cc: linux-arch@xxxxxxxxxxxxxxx --- 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); -- To unsubscribe from this list: send the line "unsubscribe linux-arch" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html