From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030295AbXDKTt5 (ORCPT ); Wed, 11 Apr 2007 15:49:57 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1030297AbXDKTt5 (ORCPT ); Wed, 11 Apr 2007 15:49:57 -0400 Received: from mail.screens.ru ([213.234.233.54]:43934 "EHLO mail.screens.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030295AbXDKTt4 (ORCPT ); Wed, 11 Apr 2007 15:49:56 -0400 Date: Wed, 11 Apr 2007 23:49:21 +0400 From: Oleg Nesterov To: "Eric W. Biederman" 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) Message-ID: <20070411194921.GA171@tv-sign.ru> References: <20070410185133.GA104@tv-sign.ru> <20070411000316.52f2551e.akpm@linux-foundation.org> <20070411192809.GA106@tv-sign.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.11 Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org On 04/11, Eric W. Biederman wrote: > > 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... Ah yes, we still need to export kthreadd_task... I just worried about subtle dependency this patch adds... This "kthreadd_task = find_task_by_pid" assumes that init/main.c:init() takes lock_kernel() before the first kthread_create(). Oleg.