Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 94dcf29a authored by Eric Dumazet's avatar Eric Dumazet Committed by Linus Torvalds
Browse files

kthread: use kthread_create_on_node()



ksoftirqd, kworker, migration, and pktgend kthreads can be created with
kthread_create_on_node(), to get proper NUMA affinities for their stack and
task_struct.

Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Acked-by: default avatarDavid S. Miller <davem@davemloft.net>
Reviewed-by: default avatarAndi Kleen <ak@linux.intel.com>
Acked-by: default avatarRusty Russell <rusty@rustcorp.com.au>
Acked-by: default avatarTejun 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 207205a2
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -845,7 +845,10 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
	switch (action) {
	switch (action) {
	case CPU_UP_PREPARE:
	case CPU_UP_PREPARE:
	case CPU_UP_PREPARE_FROZEN:
	case CPU_UP_PREPARE_FROZEN:
		p = kthread_create(run_ksoftirqd, hcpu, "ksoftirqd/%d", hotcpu);
		p = kthread_create_on_node(run_ksoftirqd,
					   hcpu,
					   cpu_to_node(hotcpu),
					   "ksoftirqd/%d", hotcpu);
		if (IS_ERR(p)) {
		if (IS_ERR(p)) {
			printk("ksoftirqd for %i failed\n", hotcpu);
			printk("ksoftirqd for %i failed\n", hotcpu);
			return notifier_from_errno(PTR_ERR(p));
			return notifier_from_errno(PTR_ERR(p));
+4 −2
Original line number Original line Diff line number Diff line
@@ -301,8 +301,10 @@ static int __cpuinit cpu_stop_cpu_callback(struct notifier_block *nfb,
	case CPU_UP_PREPARE:
	case CPU_UP_PREPARE:
		BUG_ON(stopper->thread || stopper->enabled ||
		BUG_ON(stopper->thread || stopper->enabled ||
		       !list_empty(&stopper->works));
		       !list_empty(&stopper->works));
		p = kthread_create(cpu_stopper_thread, stopper, "migration/%d",
		p = kthread_create_on_node(cpu_stopper_thread,
				   cpu);
					   stopper,
					   cpu_to_node(cpu),
					   "migration/%d", cpu);
		if (IS_ERR(p))
		if (IS_ERR(p))
			return notifier_from_errno(PTR_ERR(p));
			return notifier_from_errno(PTR_ERR(p));
		get_task_struct(p);
		get_task_struct(p);
+4 −2
Original line number Original line Diff line number Diff line
@@ -1366,7 +1366,9 @@ static struct worker *create_worker(struct global_cwq *gcwq, bool bind)
	worker->id = id;
	worker->id = id;


	if (!on_unbound_cpu)
	if (!on_unbound_cpu)
		worker->task = kthread_create(worker_thread, worker,
		worker->task = kthread_create_on_node(worker_thread,
						      worker,
						      cpu_to_node(gcwq->cpu),
						      "kworker/%u:%d", gcwq->cpu, id);
						      "kworker/%u:%d", gcwq->cpu, id);
	else
	else
		worker->task = kthread_create(worker_thread, worker,
		worker->task = kthread_create(worker_thread, worker,
+4 −1
Original line number Original line Diff line number Diff line
@@ -3761,7 +3761,10 @@ static int __init pktgen_create_thread(int cpu)
	list_add_tail(&t->th_list, &pktgen_threads);
	list_add_tail(&t->th_list, &pktgen_threads);
	init_completion(&t->start_done);
	init_completion(&t->start_done);


	p = kthread_create(pktgen_thread_worker, t, "kpktgend_%d", cpu);
	p = kthread_create_on_node(pktgen_thread_worker,
				   t,
				   cpu_to_node(cpu),
				   "kpktgend_%d", cpu);
	if (IS_ERR(p)) {
	if (IS_ERR(p)) {
		pr_err("kernel_thread() failed for cpu %d\n", t->cpu);
		pr_err("kernel_thread() failed for cpu %d\n", t->cpu);
		list_del(&t->th_list);
		list_del(&t->th_list);