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]
Date:   Tue, 25 Oct 2016 16:03:33 +0200
From:   Oleg Nesterov <oleg@...hat.com>
To:     Roman Pen <roman.penyaev@...fitbricks.com>
Cc:     Andy Lutomirski <luto@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Tejun Heo <tj@...nel.org>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 1/1] kthread: allocate kthread structure using
        kmalloc

On 10/25, Roman Pen wrote:
>
> This patch avoids allocation of kthread structure on a stack, and simply
> uses kmalloc.

Oh. I didn't even read this patch, but I have to admit I personally do not
like it. I can be wrong, but imo this is the step to the wrong direction.

struct kthread is already bloated, we should not bloat it more. Instead
we should kill it. And to_kthread() too, at least in its current form.

For example. parked/exited/cpu should go into smp_hotplug_thread. Yes,
this needs cleanups.

All we need is kthread_data() which returns the pointer to the private
data used by kthread.

As for kthread_stop(), we no longer need to abuse ->vfork_done, we can
use task_works:

	struct xxx {
		struct struct callback_head work;
		struct completion done;
	};

	static void kthread_signal_exit(struct callback_head *arg)
	{
		struct xxx *xxx = container_of(arg);
		complete(xxx->done);
	}

	int kthread_stop(struct task_struct *k)
	{
		struct xxx xxx;
		int ret;

		init_task_work(&xxx.work, kthread_signal_exit);
		init_completion(&xxx.done);

		trace_sched_kthread_stop(k);

		get_task_struct(k);
		if (!task_work_add(k, &xxx.work, false)) {
			set(KTHREAD_SHOULD_STOP);
			wake_up_process(k);
			wait_for_completion(&xxx.done);
		}
		ret = k->exit_code;
		put_task_struct(k);

		trace_sched_kthread_stop_ret(ret);
		return ret;
	}

Oleg.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ