All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Josh Triplett <josh@joshtriplett.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	Andrew Morton <akpm@linux-foundation.org>,
	Andy Lutomirski <luto@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Kees Cook <keescook@chromium.org>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	"H. Peter Anvin" <hpa@zytor.com>, Rik van Riel <riel@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Michael Kerrisk <mtk.manpages@gmail.com>,
	Thiago Macieira <thiago.macieira@intel.com>,
	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
Date: Fri, 20 Mar 2015 19:14:04 +0100	[thread overview]
Message-ID: <20150320181404.GA26343@redhat.com> (raw)
In-Reply-To: <20150315233439.GA31890@thin>

Josh,

I am really sorry for delay.

On 03/15, Josh Triplett wrote:
>
> On Sun, Mar 15, 2015 at 08:55:06PM +0100, Oleg Nesterov wrote:
 >
> > 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.
>
> Will the approach I suggested, of having clones with CLONE_THREAD
> inherit the autoreap value rather than setting it from CLONE_AUTOREAP,
> implement the semantics you're looking for?

Not sure I understand... CLONE_THREAD should not inherit the autoreap.
A sub-thread is always autoreapable.

> Also, are you suggesting that CLONE_AUTOREAP with CLONE_THREAD should
> produce -EINVAL, or just that it should be ignored?

Yes, I think CLONE_AUTOREAP | CLONE_THREAD should return -EINVAL. But
this all is minor...

The main problem is how/when we should check this "autoreap" without
making this code even more ugly.

I still think we need a preparation patch. I tried to make it today but
failed. Will try again on weekend...


Note that we can't solely rely on do_notify_parent() which (with your patch)
correctly checks !ptrace && autoreap.

Just for example. Please look at __ptrace_detach(). Note that if we add
CLONE_AUTOREAP this needs a fix in any case. The tracee can be "autoreap"
but zombie, because "autoreap" should be ignored until the tracer detaches.
But the "same_thread_group" should not call do_notify_parent() again. So
this needs another check.

And let me quote our discussion from the previous email:

	> > 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.

Yes, I agree...

But the changes in __ptrace_detach() depend on whether we need to send a signal
or not. Either way the changle is simple, but looks ugly. It would be nice to
cleanup this somehow.

Also. I forgot that the kernel always resets ->exit_signal to SIGCHLD on exec
or reparenting. Reparenting is probably fine. But what about exec? Should it
keep ->exit_signal == 0 if "autoreap" ? I think it should not, to avoid the
strange special case.

> > > > 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 ;)

And this too asks for preparation before CLONE_AUTOREAP...

So I'll try to think about this all again on weekend. I'll try very much
to not disappear again ;)

Oleg.

  reply	other threads:[~2015-03-20 18:14 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-15  7:59 [PATCH v2 0/7] CLONE_FD: Task exit notification via file descriptor Josh Triplett
2015-03-15  7:59 ` Josh Triplett
2015-03-15  7:59 ` [PATCH v2 1/7] clone: Support passing tls argument via C rather than pt_regs magic Josh Triplett
     [not found] ` <cover.1426376419.git.josh-iaAMLnmF4UmaiuxdJuQwMA@public.gmane.org>
2015-03-15  7:59   ` [PATCH v2 2/7] x86: Opt into HAVE_COPY_THREAD_TLS, for both 32-bit and 64-bit Josh Triplett
2015-03-15  7:59     ` Josh Triplett
2015-03-15  8:04   ` [PATCH v2 0/7] CLONE_FD: Task exit notification via file descriptor Josh Triplett
2015-03-15  8:04     ` Josh Triplett
2015-05-29  7:43   ` Florian Weimer
2015-05-29  7:43     ` Florian Weimer
2015-05-29 20:27     ` Thiago Macieira
2015-06-15 10:06       ` Florian Weimer
2015-06-15 10:06         ` Florian Weimer
2015-03-15  7:59 ` [PATCH v2 3/7] Introduce a new clone4 syscall with more flag bits and extensible arguments Josh Triplett
     [not found]   ` <367b888ef58831b6812c3cf80ca973c65edc67f5.1426376419.git.josh-iaAMLnmF4UmaiuxdJuQwMA@public.gmane.org>
2015-03-23 14:11     ` David Drysdale
2015-03-23 14:11       ` David Drysdale
2015-03-23 15:05       ` josh
2015-03-31 14:41         ` David Drysdale
2015-03-15  7:59 ` [PATCH v2 4/7] kernel/fork.c: Pass arguments to _do_fork and copy_process using clone4_args Josh Triplett
2015-03-15  8:00 ` [PATCH v2 5/7] clone4: Add a CLONE_AUTOREAP flag to automatically reap the child process Josh Triplett
     [not found]   ` <6d002995485d446e659105f6931307f3e532ce89.1426376419.git.josh-iaAMLnmF4UmaiuxdJuQwMA@public.gmane.org>
2015-03-15 14:52     ` Oleg Nesterov
2015-03-15 14:52       ` Oleg Nesterov
     [not found]       ` <20150315145223.GA21887-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-03-15 17:18         ` Josh Triplett
2015-03-15 17:18           ` Josh Triplett
2015-03-15 19:55           ` Oleg Nesterov
2015-03-15 19:55             ` Oleg Nesterov
     [not found]             ` <20150315195506.GA29475-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-03-15 23:34               ` Josh Triplett
2015-03-15 23:34                 ` Josh Triplett
2015-03-20 18:14                 ` Oleg Nesterov [this message]
2015-03-20 18:46                   ` Thiago Macieira
2015-03-20 19:09                     ` Oleg Nesterov
2015-03-20 19:09                       ` Oleg Nesterov
2015-03-20 21:10                       ` josh
2015-03-15  8:00 ` [PATCH v2 6/7] signal: Factor out a helper function to process task_struct exit_code Josh Triplett
2015-03-15  8:00 ` [PATCH v2 7/7] clone4: Add a CLONE_FD flag to get task exit notification via fd Josh Triplett
2015-03-23 17:38   ` David Drysdale
2015-03-25 14:53     ` Josh Triplett
     [not found]   ` <fdec4b70c7cd34e2eacf6a0e41d36f606a696da1.1426376419.git.josh-iaAMLnmF4UmaiuxdJuQwMA@public.gmane.org>
2015-04-06  8:30     ` Sergey Senozhatsky
2015-04-06  8:30       ` Sergey Senozhatsky
2015-04-06  9:31       ` Josh Triplett
2015-04-06  9:31         ` Josh Triplett
2015-03-15  8:00 ` [PATCH v2 man-pages] clone4.2: New manpage documenting clone4(2) Josh Triplett
2015-03-16 21:44 ` [PATCH v2 0/7] CLONE_FD: Task exit notification via file descriptor Kees Cook
2015-03-16 21:44   ` Kees Cook
     [not found]   ` <CAGXu5jLmLLgVNCP=cyUiXuiszVXsS88SNUK2iBqArbA2V6vdHA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-03-16 22:14     ` Thiago Macieira
2015-03-16 22:14       ` Thiago Macieira
2015-03-16 22:36       ` Kees Cook
     [not found]         ` <CAGXu5jJr_DieZ281=H0ZNtNvOagO0pm8PRfNvRWKp4YwS=55GA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-03-16 22:50           ` Thiago Macieira
2015-03-16 22:50             ` Thiago Macieira
2015-03-16 23:26             ` Kees Cook
2015-03-16 23:35         ` josh
2015-03-16 23:29       ` josh-iaAMLnmF4UmaiuxdJuQwMA
2015-03-16 23:29         ` josh
2015-03-17  0:49         ` Thiago Macieira
2015-03-17  0:49           ` Thiago Macieira
2015-03-23 14:12         ` David Drysdale
2015-03-23 15:03           ` josh
2015-03-16 23:25     ` josh-iaAMLnmF4UmaiuxdJuQwMA
2015-03-16 23:25       ` josh
2015-03-31 20:08 ` Jonathan Corbet
2015-03-31 22:02   ` josh
2015-04-01  7:24     ` Jonathan Corbet
     [not found]       ` <20150401092420.4c1dbb6e-T1hC0tSOHrs@public.gmane.org>
2015-04-09  2:19         ` Josh Triplett
2015-04-09  2:19           ` Josh Triplett

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150320181404.GA26343@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=josh@joshtriplett.org \
    --cc=keescook@chromium.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=mtk.manpages@gmail.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=riel@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=thiago.macieira@intel.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.