lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-8fb9dcbdc3619741c10c573199d804161c34c89a@git.kernel.org>
Date:   Thu, 8 Dec 2016 05:45:12 -0800
From:   tip-bot for Oleg Nesterov <tipbot@...or.com>
To:     linux-tip-commits@...r.kernel.org
Cc:     tglx@...utronix.de, luto@...capital.net, David1.Zhou@....com,
        roman.penyaev@...fitbricks.com, linux-kernel@...r.kernel.org,
        oleg@...hat.com, tj@...nel.org, peterz@...radead.org,
        luto@...nel.org, mingo@...nel.org, akpm@...ux-foundation.org,
        alexander.deucher@....com, hpa@...or.com, pmladek@...e.com
Subject: [tip:sched/core] kthread: Don't abuse kthread_create_on_cpu() in
 __kthread_create_worker()

Commit-ID:  8fb9dcbdc3619741c10c573199d804161c34c89a
Gitweb:     http://git.kernel.org/tip/8fb9dcbdc3619741c10c573199d804161c34c89a
Author:     Oleg Nesterov <oleg@...hat.com>
AuthorDate: Tue, 29 Nov 2016 18:51:10 +0100
Committer:  Thomas Gleixner <tglx@...utronix.de>
CommitDate: Thu, 8 Dec 2016 14:36:20 +0100

kthread: Don't abuse kthread_create_on_cpu() in __kthread_create_worker()

kthread_create_on_cpu() sets KTHREAD_IS_PER_CPU and kthread->cpu, this
only makes sense if this kthread can be parked/unparked by cpuhp code.
kthread workers never call kthread_parkme() so this has no effect.

Change __kthread_create_worker() to simply call kthread_bind(task, cpu).
The very fact that kthread_create_on_cpu() doesn't accept a generic fmt
shows that it should not be used outside of smpboot.c.

Now, the only reason we can not unexport this helper and move it into
smpboot.c is that it sets kthread->cpu and struct kthread is not exported.
And the only reason we can not kill kthread->cpu is that kthread_unpark()
is used by drivers/gpu/drm/amd/scheduler/gpu_scheduler.c and thus we can
not turn _unpark into kthread_unpark(struct smp_hotplug_thread *, cpu).

Signed-off-by: Oleg Nesterov <oleg@...hat.com>
Tested-by: Petr Mladek <pmladek@...e.com>
Acked-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Reviewed-by: Petr Mladek <pmladek@...e.com>
Cc: Chunming Zhou <David1.Zhou@....com>
Cc: Roman Pen <roman.penyaev@...fitbricks.com>
Cc: Andy Lutomirski <luto@...capital.net>
Cc: Tejun Heo <tj@...nel.org>
Cc: Andy Lutomirski <luto@...nel.org>
Cc: Alex Deucher <alexander.deucher@....com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Link: http://lkml.kernel.org/r/20161129175110.GA5342@redhat.com
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>

---
 kernel/kthread.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/kernel/kthread.c b/kernel/kthread.c
index 01d2716..956495f 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -641,6 +641,7 @@ __kthread_create_worker(int cpu, unsigned int flags,
 {
 	struct kthread_worker *worker;
 	struct task_struct *task;
+	int node = -1;
 
 	worker = kzalloc(sizeof(*worker), GFP_KERNEL);
 	if (!worker)
@@ -648,25 +649,17 @@ __kthread_create_worker(int cpu, unsigned int flags,
 
 	kthread_init_worker(worker);
 
-	if (cpu >= 0) {
-		char name[TASK_COMM_LEN];
-
-		/*
-		 * kthread_create_worker_on_cpu() allows to pass a generic
-		 * namefmt in compare with kthread_create_on_cpu. We need
-		 * to format it here.
-		 */
-		vsnprintf(name, sizeof(name), namefmt, args);
-		task = kthread_create_on_cpu(kthread_worker_fn, worker,
-					     cpu, name);
-	} else {
-		task = __kthread_create_on_node(kthread_worker_fn, worker,
-						-1, namefmt, args);
-	}
+	if (cpu >= 0)
+		node = cpu_to_node(cpu);
 
+	task = __kthread_create_on_node(kthread_worker_fn, worker,
+						node, namefmt, args);
 	if (IS_ERR(task))
 		goto fail_task;
 
+	if (cpu >= 0)
+		kthread_bind(task, cpu);
+
 	worker->flags = flags;
 	worker->task = task;
 	wake_up_process(task);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ