[PATCH v2 0/3] make vfork killable

Oleg Nesterov
2011-08-12T17:58:51Z

Hi Tejun,

On 07/29, Tejun Heo wrote:
>
> If the current implementation is too nasty,

OK, I agree, the patches I sent doesn't look very clear/clean.

But,

> an alternative approach
> could be handling vfork waiting as a type of job control stop.

Well, I didn't see the code, but to be honest this doesn't look
like a good idea to me. Firstly, personally I do not think this
has something to do with the job control stop.

And, to me sys_restart_syscall() looks like the very natural
approach, and simple.

> * When entering get_signal_to_deliver(), if vfork child exists, save
> sigmask and block all blockable signals.

Oh, I'd like to avoid this. Why should we change get_signal_to_deliver()
paths to help vfork?

> * When leaving get_signal_to_deliver(), restore sigmask if saved on
> entry.

And I _think_ we need much more complications. We still need to
communicate with the child, for example. Unless we are going to
add the "struct completion vfork_done" or something into task_struct,
personally I dislike this idea.

> Haven't really thought a lot about the details so this might end up
> uglier than the current attempt. :)

I _hope_ it is much uglier, but I can be wrong of course ;)

OK. Can't we make the first step at least? Make it killable. I think
this will simplify the next changes anyway.

So. This seried makes vfork() killable. No restarts, just
s/wait_for_completion/wait_for_completion_killable/ + clear
child->vfork_done if killed.

The only overhead this patch adds to CLONE_VFORK

- parent does get_task_struct() + put_task_struct()

- child does task_lock() + task_unlock()

4/3 is off-topic, somehow I hate PF_STARTING irrationally. and it
helps to make the diffstat below better ;)

Oleg.

fs/exec.c | 18 +-------------
include/linux/sched.h | 1 -
kernel/fork.c | 61 +++++++++++++++++++++++++++++++-----------------
3 files changed, 41 insertions(+), 39 deletions(-)