From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752589AbbCNTtS (ORCPT ); Sat, 14 Mar 2015 15:49:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42280 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751300AbbCNTtO (ORCPT ); Sat, 14 Mar 2015 15:49:14 -0400 Date: Sat, 14 Mar 2015 20:47:21 +0100 From: Oleg Nesterov To: Josh Triplett Cc: Thiago Macieira , Al Viro , Andrew Morton , Andy Lutomirski , Ingo Molnar , Kees Cook , "Paul E. McKenney" , "H. Peter Anvin" , Rik van Riel , Thomas Gleixner , Michael Kerrisk , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH 6/6] clone4: Introduce new CLONE_FD flag to get task exit notification via fd Message-ID: <20150314194721.GA9654@redhat.com> References: <20150314141414.GA11062@redhat.com> <20150314143235.GA12086@redhat.com> <28025621.k7WkrfHd4d@tjmaciei-mobl4> <20150314190132.GB22130@thin> <20150314191836.GA8416@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150314191836.GA8416@redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/14, Oleg Nesterov wrote: > > On 03/14, Josh Triplett wrote: > > > > On Sat, Mar 14, 2015 at 11:38:29AM -0700, Thiago Macieira wrote: > > > On Saturday 14 March 2015 15:32:35 Oleg Nesterov wrote: > > > > It is not clear to me what do_wait() should do with ->autoreap child, even > > > > ignoring ptrace. > > > > > > > > Just suppose that real_parent has a single "autoreap" child. Should > > > > wait(NULL) hanf then? > > > > > > It should ignore the child that is set to autoreap. wait(NULL) should return - > > > ECHILD, indicating there are no children waiting to be reaped. > > > > Right. And I don't think the current code does this. I think we need > > to change wait_consider_task to early-return for ->autoreap just as it > > does for task_state == EXIT_DEAD. > > No. This EXIT_DEAD is absolutely different. And this is another indication > that you might use it wrongly ;) > > What we actually want is BUG_ON(task_state == EXIT_DEAD) here. We do not > want the EXIT_DEAD tasks in ->children/ptraced lists. These EXIT_DEAD tasks > complicate the exit/wait/reparent paths. > > However, currently this is TODO. The main problem is the locking in > wait_task_zombie(), we can set EXIT_DEAD and remove the task from list > under read_lock(). Let me clarify in case I confused you. The EXIT_DEAD check in do_wait() paths doesn't mean "autoreap". It means that this thread/process (depending on ptrace) was already reaped. It was reaped by our sub-thread, or it was reaped because we ignore SIGCHLD, or other reasons. This doesn't matter. In short, EXIT_DEAD means: we have to keep this thread on lists until the task which set this state calls release_task(). Oleg. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Oleg Nesterov Subject: Re: [PATCH 6/6] clone4: Introduce new CLONE_FD flag to get task exit notification via fd Date: Sat, 14 Mar 2015 20:47:21 +0100 Message-ID: <20150314194721.GA9654@redhat.com> References: <20150314141414.GA11062@redhat.com> <20150314143235.GA12086@redhat.com> <28025621.k7WkrfHd4d@tjmaciei-mobl4> <20150314190132.GB22130@thin> <20150314191836.GA8416@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Thiago Macieira , Al Viro , Andrew Morton , Andy Lutomirski , Ingo Molnar , Kees Cook , "Paul E. McKenney" , "H. Peter Anvin" , Rik van Riel , Thomas Gleixner , Michael Kerrisk , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org To: Josh Triplett Return-path: Content-Disposition: inline In-Reply-To: <20150314191836.GA8416-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: linux-fsdevel.vger.kernel.org On 03/14, Oleg Nesterov wrote: > > On 03/14, Josh Triplett wrote: > > > > On Sat, Mar 14, 2015 at 11:38:29AM -0700, Thiago Macieira wrote: > > > On Saturday 14 March 2015 15:32:35 Oleg Nesterov wrote: > > > > It is not clear to me what do_wait() should do with ->autoreap child, even > > > > ignoring ptrace. > > > > > > > > Just suppose that real_parent has a single "autoreap" child. Should > > > > wait(NULL) hanf then? > > > > > > It should ignore the child that is set to autoreap. wait(NULL) should return - > > > ECHILD, indicating there are no children waiting to be reaped. > > > > Right. And I don't think the current code does this. I think we need > > to change wait_consider_task to early-return for ->autoreap just as it > > does for task_state == EXIT_DEAD. > > No. This EXIT_DEAD is absolutely different. And this is another indication > that you might use it wrongly ;) > > What we actually want is BUG_ON(task_state == EXIT_DEAD) here. We do not > want the EXIT_DEAD tasks in ->children/ptraced lists. These EXIT_DEAD tasks > complicate the exit/wait/reparent paths. > > However, currently this is TODO. The main problem is the locking in > wait_task_zombie(), we can set EXIT_DEAD and remove the task from list > under read_lock(). Let me clarify in case I confused you. The EXIT_DEAD check in do_wait() paths doesn't mean "autoreap". It means that this thread/process (depending on ptrace) was already reaped. It was reaped by our sub-thread, or it was reaped because we ignore SIGCHLD, or other reasons. This doesn't matter. In short, EXIT_DEAD means: we have to keep this thread on lists until the task which set this state calls release_task(). Oleg.