lkml.org 
[lkml]   [2012]   [Feb]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/4] vfork: make it killable
On Thu, 16 Feb 2012 18:27:06 +0100
Oleg Nesterov <oleg@redhat.com> wrote:

> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -669,10 +669,34 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
>
> void complete_vfork_done(struct task_struct *tsk)
> {
> - struct completion *vfork_done = tsk->vfork_done;
> + struct completion *vfork;
>
> - tsk->vfork_done = NULL;
> - complete(vfork_done);
> + task_lock(tsk);
> + vfork = tsk->vfork_done;
> + if (likely(vfork)) {
> + tsk->vfork_done = NULL;
> + complete(vfork);
> + }
> + task_unlock(tsk);
> +}

OK, so now we don't need to test tsk->vfork_done in callers. But
mm_release() still does this, and it does it outside locks. Mistake,
or micro-optimisation? If the latter, why is the lockless peek
race-free?



\
 
 \ /
  Last update: 2012-02-17 01:41    [W:0.128 / U:0.672 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site