From: Oleg Nesterov <oleg@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Roland McGrath <roland@hack.frob.com>, Tejun Heo <tj@kernel.org>,
Denys Vlasenko <dvlasenk@redhat.com>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Matt Fleming <matt.fleming@linux.intel.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/8] make vfork killable/restartable/traceable
Date: Thu, 28 Jul 2011 15:59:58 +0200 [thread overview]
Message-ID: <20110728135958.GA9069@redhat.com> (raw)
In-Reply-To: <CA+55aFy83CAZ+AVZNtYZc=NnOzaxsQxksuspqBHGVwLx4hvMCg@mail.gmail.com>
On 07/27, Linus Torvalds wrote:
>
> On Wed, Jul 27, 2011 at 9:31 AM, Oleg Nesterov <oleg@redhat.com> wrote:
> >
> > CLONE_VFORK sleeps in TASK_INTERRUPTIBLE until the child exits/execs.
> > This is obviously not good, it is sooo simple to create the task which
> > doesn't react to SIGKILL/SIGSTOP.
>
> Well, I don't know how bad that is.
Well, me to. That is why 0/9 starts with "do we really need this?".
I expected you won't be happy ;)
However.
> You just kill the child instead.
Sure. Assuming you know what happens and who should be killed.
Yes, it is not that hard to figure out. Still. vfork() is the
only example which allows to create the unkillable/unstoppable
task in a trivial way.
> And quite frankly, I think your patches 1-3 are unbelievably ugly. If
> it was some simple and straightforward "use
> wait_for_completion_killable() instead", I wouldn't mind it. But I
> think you made a simple and clean sequence convoluted and annoying.
Yes. This doesn't make the code simpler. I agree. The question is,
are they are more ugly then necessary. May be... I'll try to think
a bit more.
And just in case. Personally I think that "unstoppable" is worse
than "unkillable". Suppose that you run the "good" application
which doesn't abuse vfork/signals but does something like
if (!vfork()) {
do_simething();
execve(...);
}
In this case ^C always works, even if do_something() blocks for
some reason.
But it is quite possible that ^Z "hangs" just because it races
with vfork().
> I *suspect* that the killable() thing could be done more nicely by
> moving the vfork_completion into the parent instead, and maybe the
> vfork cleanup could just use
> "complete(&task->parent->vfork_completion);" instead
I thought about moving the "vfork_done" thing (in some form) from
child to parent. So far I do not see a clean solution.
For example. If we simply use ->real_parent->vfork_completion, then
yes, we do not need to communicate with the child, the child can rely
on rcu to ensure "struct completion" can't go away. But, this bloats
task_struct a bit, and:
> (so if the parent
> goes away, it completes some irrelevant init case instead).
This assumes /sbin/init can't sleep in CLONE_VFORK. So we need some
complications again.
Not to mention, kthread/kthread_stop should be reworked somehow.
> especially since it's not a real problem
Well. Personally I don't agree.
I'll try to simplify the patches. I am not sure I can do something
really simple.
For example, 3/8 can do
// called by mm_release()
void complete_vfork_done(struct task_struct *tsk)
{
struct completion *vfork_done;
task_lock(tsk);
vfork_done = tsk->vfork_done;
if (vfork_done) {
tsk->vfork_done = NULL; // UNNEEDED
complete(vfork_done);
}
task_unlock(tsk);
}
// used by do fork instead of wait_for_completion()
static long wait_for_vfork_done(struct task_struct *child,
struct completion *vfork_done)
{
int killed = wait_for_completion_killable(vfork_done);
if (killed) {
task_lock(tsk);
child->vfork_done = NULL;
task_unlock(tsk);
return -EINTR;
}
return 0;
}
Does this look "not too ugly" to you or not?
Oleg.
next prev parent reply other threads:[~2011-07-28 14:03 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-27 16:31 [PATCH 0/8] make vfork killable/restartable/traceable Oleg Nesterov
2011-07-27 16:32 ` [PATCH 1/8] vfork: introduce complete_vfork_done() Oleg Nesterov
2011-07-27 16:32 ` [PATCH 2/8] vfork: introduce clone_vfork_finish() Oleg Nesterov
2011-07-27 16:32 ` [PATCH 3/8] vfork: make it killable Oleg Nesterov
2011-07-29 13:02 ` Matt Fleming
2011-07-29 14:32 ` Oleg Nesterov
2011-07-29 15:32 ` Matt Fleming
2011-07-27 16:33 ` [PATCH 4/8] coredump_wait: don't call complete_vfork_done() Oleg Nesterov
2011-07-29 13:02 ` Matt Fleming
2011-07-29 14:25 ` Oleg Nesterov
2011-07-29 15:26 ` Matt Fleming
2011-07-27 16:33 ` [PATCH 5/8] introduce find_get_task_by_vpid() Oleg Nesterov
2011-07-27 16:33 ` [PATCH 6/8] vfork: do not setup child->vfork_done beforehand Oleg Nesterov
2011-07-27 16:34 ` [PATCH 7/8] vfork: make it stoppable/traceable Oleg Nesterov
2011-07-27 16:34 ` [PATCH 8/8] vfork: do not block SIG_DFL/SIG_IGN signals is single-threaded Oleg Nesterov
2011-07-27 16:34 ` [PATCH 9/8] kill PF_STARTING Oleg Nesterov
2011-07-27 19:39 ` [PATCH 0/8] make vfork killable/restartable/traceable Linus Torvalds
2011-07-28 13:59 ` Oleg Nesterov [this message]
2011-07-28 14:58 ` Oleg Nesterov
2011-07-27 22:38 ` Pedro Alves
2011-07-29 19:23 ` Tejun Heo
2011-08-12 17:55 ` [PATCH v2 0/3] make vfork killable Oleg Nesterov
2011-08-12 17:56 ` [PATCH 1/3] vfork: introduce complete_vfork_done() Oleg Nesterov
2011-08-12 17:56 ` [PATCH 2/3] vfork: make it killable Oleg Nesterov
2011-08-19 20:33 ` Matt Fleming
2011-08-22 13:35 ` Oleg Nesterov
2011-08-12 17:56 ` [PATCH 3/3] coredump_wait: don't call complete_vfork_done() Oleg Nesterov
2011-08-17 7:50 ` Tejun Heo
2011-08-17 15:11 ` Oleg Nesterov
2011-08-12 17:57 ` [PATCH 4/3] kill PF_STARTING Oleg Nesterov
2011-08-17 7:51 ` Tejun Heo
2011-08-13 16:18 ` [PATCH v2 0/3] make vfork killable Tejun Heo
2011-08-15 19:42 ` Oleg Nesterov
2011-08-16 19:42 ` Tejun Heo
2011-08-23 22:01 ` Matt Helsley
2011-08-23 22:12 ` Tejun Heo
[not found] ` <20110727163610.GJ23793@redhat.com>
[not found] ` <20110727175624.GA3950@redhat.com>
[not found] ` <20110728154324.GA22864@redhat.com>
[not found] ` <alpine.DEB.2.00.1107281341060.16093@chino.kir.corp.google.com>
[not found] ` <20110729141431.GA3501@redhat.com>
[not found] ` <20110730143426.GA6061@redhat.com>
2011-07-30 15:22 ` mm->oom_disable_count is broken Oleg Nesterov
2011-08-01 11:52 ` KOSAKI Motohiro
2011-08-29 18:37 ` Oleg Nesterov
2011-08-29 23:17 ` David Rientjes
2011-08-30 7:43 ` [patch 1/2] oom: remove oom_disable_count David Rientjes
2011-08-30 7:43 ` [patch 2/2] oom: fix race while temporarily setting current's oom_score_adj David Rientjes
2011-08-30 15:57 ` Oleg Nesterov
2011-08-30 15:28 ` [patch 1/2] oom: remove oom_disable_count Oleg Nesterov
2011-08-30 22:06 ` David Rientjes
2011-08-30 16:17 ` mm->oom_disable_count is broken Oleg Nesterov
2011-08-10 21:44 ` [PATCH 0/8] make vfork killable/restartable/traceable Pavel Machek
2011-08-11 16:09 ` Oleg Nesterov
2011-08-11 16:22 ` Tejun Heo
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=20110728135958.GA9069@redhat.com \
--to=oleg@redhat.com \
--cc=dvlasenk@redhat.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matt.fleming@linux.intel.com \
--cc=roland@hack.frob.com \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox