From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030224AbXDKTmx (ORCPT ); Wed, 11 Apr 2007 15:42:53 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1030241AbXDKTmx (ORCPT ); Wed, 11 Apr 2007 15:42:53 -0400 Received: from ebiederm.dsl.xmission.com ([166.70.28.69]:32945 "EHLO ebiederm.dsl.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030224AbXDKTmw (ORCPT ); Wed, 11 Apr 2007 15:42:52 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: Oleg Nesterov Cc: Andrew Morton , Davide Libenzi , Jan Engelhardt , Ingo Molnar , Linus Torvalds , Robin Holt , Roland McGrath , "Serge E. Hallyn" , linux-kernel@vger.kernel.org, "Rafael J. Wysocki" , Gautham R Shenoy Subject: Re: [PATCH] kthread: Don't depend on work queues (take 2) References: <20070410185133.GA104@tv-sign.ru> <20070411000316.52f2551e.akpm@linux-foundation.org> <20070411192809.GA106@tv-sign.ru> Date: Wed, 11 Apr 2007 13:40:23 -0600 In-Reply-To: <20070411192809.GA106@tv-sign.ru> (Oleg Nesterov's message of "Wed, 11 Apr 2007 23:28:09 +0400") Message-ID: User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Oleg Nesterov 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