From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752286AbbCOT5T (ORCPT ); Sun, 15 Mar 2015 15:57:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36979 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751477AbbCOT5P (ORCPT ); Sun, 15 Mar 2015 15:57:15 -0400 Date: Sun, 15 Mar 2015 20:55:06 +0100 From: Oleg Nesterov To: Josh Triplett Cc: Al Viro , Andrew Morton , Andy Lutomirski , Ingo Molnar , Kees Cook , "Paul E. McKenney" , "H. Peter Anvin" , Rik van Riel , Thomas Gleixner , Michael Kerrisk , Thiago Macieira , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH v2 5/7] clone4: Add a CLONE_AUTOREAP flag to automatically reap the child process Message-ID: <20150315195506.GA29475@redhat.com> References: <6d002995485d446e659105f6931307f3e532ce89.1426376419.git.josh@joshtriplett.org> <20150315145223.GA21887@redhat.com> <20150315171855.GA30620@thin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150315171855.GA30620@thin> 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/15, Josh Triplett wrote: > > On Sun, Mar 15, 2015 at 03:52:23PM +0100, Oleg Nesterov wrote: > > On 03/15, Josh Triplett wrote: > > > Add a CLONE_AUTOREAP flag to request this behavior unconditionally, > > > > Yes, CLONE_AUTOREAP is much better. And I agree (mostly) with that > > we should rely on do_notify_parent(). > > > > Howver the patch still doesn't look right. First of all, ->autoreap > > should be per-process, not per-thread. > > Ah, you're thinking of the case where the parent process launches a > ... Not really, although we probably need more sanity checks. It should be per-process simply because this "autoreap" affects the whole process. And the sub-threads are already "autoreap". And these 2 autoreap's semantics differ, we should not confuse them. > (As an aside, what *is* the use case for CLONE_PARENT without > CLONE_THREAD?) To me CLONE_PARENT is another historical mistake and the source of misc problems ;) > > And there are ptrace/mt issues, > > it seems. Just for example, we should avoid EXIT_TRACE if autoreap in > > wait_task_zombie() even if we are going to re-notify parent. > > I don't see how EXIT_TRACE can happen in wait_task_zombie if autoreap is > set. wait_task_zombie does a cmpxchg with exit_state and doesn't > proceed unless exit_state was EXIT_ZOMBIE, and I don't see how we can > ever reach the EXIT_ZOMBIE state if autoreap. Because you again forgot about ptrace ;) Josh. Let me try to summarise this later when I have time. Again, I am not sure, perhaps this is even simpler than I currently think. And let me apologize in advance, most probably I will be busy tomorrow. > > EXCEPT: do we really want SIGCHLD from the exiting child? I think we > > do not. I won't really argue though, but this should be discussed and > > documented. IIUC, with your patch it is still sent. > > I think we do, yes. The caller of clone can already specify what signal > they want, including no signal at all. If they specify a signal > (SIGCHLD or otherwise) along with CLONE_AUTOREAP, we can send that > signal. OK. Agreed. Oleg. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Oleg Nesterov Subject: Re: [PATCH v2 5/7] clone4: Add a CLONE_AUTOREAP flag to automatically reap the child process Date: Sun, 15 Mar 2015 20:55:06 +0100 Message-ID: <20150315195506.GA29475@redhat.com> References: <6d002995485d446e659105f6931307f3e532ce89.1426376419.git.josh@joshtriplett.org> <20150315145223.GA21887@redhat.com> <20150315171855.GA30620@thin> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Al Viro , Andrew Morton , Andy Lutomirski , Ingo Molnar , Kees Cook , "Paul E. McKenney" , "H. Peter Anvin" , Rik van Riel , Thomas Gleixner , Michael Kerrisk , Thiago Macieira , 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: <20150315171855.GA30620@thin> Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: linux-fsdevel.vger.kernel.org On 03/15, Josh Triplett wrote: > > On Sun, Mar 15, 2015 at 03:52:23PM +0100, Oleg Nesterov wrote: > > On 03/15, Josh Triplett wrote: > > > Add a CLONE_AUTOREAP flag to request this behavior unconditionally, > > > > Yes, CLONE_AUTOREAP is much better. And I agree (mostly) with that > > we should rely on do_notify_parent(). > > > > Howver the patch still doesn't look right. First of all, ->autoreap > > should be per-process, not per-thread. > > Ah, you're thinking of the case where the parent process launches a > ... Not really, although we probably need more sanity checks. It should be per-process simply because this "autoreap" affects the whole process. And the sub-threads are already "autoreap". And these 2 autoreap's semantics differ, we should not confuse them. > (As an aside, what *is* the use case for CLONE_PARENT without > CLONE_THREAD?) To me CLONE_PARENT is another historical mistake and the source of misc problems ;) > > And there are ptrace/mt issues, > > it seems. Just for example, we should avoid EXIT_TRACE if autoreap in > > wait_task_zombie() even if we are going to re-notify parent. > > I don't see how EXIT_TRACE can happen in wait_task_zombie if autoreap is > set. wait_task_zombie does a cmpxchg with exit_state and doesn't > proceed unless exit_state was EXIT_ZOMBIE, and I don't see how we can > ever reach the EXIT_ZOMBIE state if autoreap. Because you again forgot about ptrace ;) Josh. Let me try to summarise this later when I have time. Again, I am not sure, perhaps this is even simpler than I currently think. And let me apologize in advance, most probably I will be busy tomorrow. > > EXCEPT: do we really want SIGCHLD from the exiting child? I think we > > do not. I won't really argue though, but this should be discussed and > > documented. IIUC, with your patch it is still sent. > > I think we do, yes. The caller of clone can already specify what signal > they want, including no signal at all. If they specify a signal > (SIGCHLD or otherwise) along with CLONE_AUTOREAP, we can send that > signal. OK. Agreed. Oleg.