[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1311953565.21232.72.camel@mfleming-mobl1.ger.corp.intel.com>
Date: Fri, 29 Jul 2011 16:32:45 +0100
From: Matt Fleming <matt.fleming@...ux.intel.com>
To: Oleg Nesterov <oleg@...hat.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Roland McGrath <roland@...k.frob.com>,
Tejun Heo <tj@...nel.org>,
Denys Vlasenko <dvlasenk@...hat.com>,
KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/8] vfork: make it killable
On Fri, 2011-07-29 at 16:32 +0200, Oleg Nesterov wrote:
> On 07/29, Matt Fleming wrote:
> >
> > On Wed, 2011-07-27 at 18:32 +0200, Oleg Nesterov wrote:
> >
> > [...]
> >
> > > static long clone_vfork_finish(struct task_struct *child,
> > > struct completion *vfork_done, long pid)
> > > {
> > > - freezer_do_not_count();
> > > - wait_for_completion(vfork_done);
> > > - freezer_count();
> > > + int killed = wait_for_completion_killable(vfork_done);
> > > +
> > > + if (killed) {
> > > + struct completion *steal = xchg(&child->vfork_done, NULL);
> > > + /* if we race with complete_vfork_done() we have to wait */
> > > + if (unlikely(!steal))
> > > + wait_for_completion(vfork_done);
> > > +
> > > + return -EINTR;
> > > + }
> >
> > Hmm.. isn't this inherently racy anyway? Why go to the trouble of trying
> > to handle this race at all?
>
> Suppose the child does xchg() and sees vfork_done != NULL. In this
> case the parent shouldn't return from do_fork() until the child
> does complete(), this "struct completion" was allocated on parent's
> stack.
>
> OK, I am starting to agree this looks overcomplicated, task_lock()
> can make the code look simpler (see 0/8).
Yeah, I think the code in 0/8 looks like a better solution.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists