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:	Wed, 11 Apr 2007 13:40:23 -0600
From:	ebiederm@...ssion.com (Eric W. Biederman)
To:	Oleg Nesterov <oleg@...sign.ru>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Davide Libenzi <davidel@...ilserver.org>,
	Jan Engelhardt <jengelh@...ux01.gwdg.de>,
	Ingo Molnar <mingo@...e.hu>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Robin Holt <holt@....com>, Roland McGrath <roland@...hat.com>,
	"Serge E. Hallyn" <serge@...lyn.com>, linux-kernel@...r.kernel.org,
	"Rafael J. Wysocki" <rjw@...k.pl>,
	Gautham R Shenoy <ego@...ibm.com>
Subject: Re: [PATCH] kthread: Don't depend on work queues (take 2)

Oleg Nesterov <oleg@...sign.ru> writes:

> On 04/11, Eric W. Biederman wrote:
>> 
>> @@ -435,8 +436,12 @@ static void __init setup_command_line(char *command_line)
>>  static void noinline rest_init(void)
>>  	__releases(kernel_lock)
>>  {
>> +	int pid;
>>  	kernel_thread(init, NULL, CLONE_FS | CLONE_SIGHAND);
>>  	numa_default_policy();
>> +
>> +	pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES);
>> +	kthreadd_task = find_task_by_pid(pid);
>>  	unlock_kernel();
>
> Just curious. What if kernel/kthread.c declares
>
> 	static struct task_struct *kthreadd_task = &init_task;
>
> an then kthreadd_setup() does kthreadd_task = current. I assume it is always
> safe to try_to_wake_up(idle_thread), because it always TASK_RUNNING. This
> way we don't need to export kthreadd_task.

I did it this way largely so I could use the export in reparent_to_XXX in
daemonize.  This way I don't have races in finding kthreadd.  Plus
I didn't think of the trick of using the idle_thread...

>> +	spin_lock(&kthread_create_lock);
>> +	list_add_tail(&create.list, &kthread_create_list);
>> +	wake_up_process(kthreadd_task);
>> +	spin_unlock(&kthread_create_lock);
>
> Very minor nit, but we don't need to do wake_up under spin_unlock().

I guess that is true.  However it doesn't hurt either.  I guess
I was keeping the form that I used with wait queues where it may
have mattered.  Either that or I just copied a bad example.

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ