[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <200704232205.16208.rjw@sisk.pl>
Date: Mon, 23 Apr 2007 22:05:15 +0200
From: "Rafael J. Wysocki" <rjw@...k.pl>
To: Oleg Nesterov <oleg@...sign.ru>
Cc: Gautham R Shenoy <ego@...ibm.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Ingo Molnar <mingo@...e.hu>, linux-kernel@...r.kernel.org,
vatsa@...ibm.com, paulmck@...ibm.com, pavel@....cz
Subject: Re: [RFC][PATCH -mm 3/3] freezer: Fix problem with kthread_stop
On Monday, 23 April 2007 21:03, Oleg Nesterov wrote:
> On 04/23, Gautham R Shenoy wrote:
> >
> > On Sun, Apr 22, 2007 at 09:40:59PM +0200, Rafael J. Wysocki wrote:
> > > /*
> > > @@ -232,6 +233,14 @@ int kthread_stop(struct task_struct *k)
> > >
> > > /* Now set kthread_should_stop() to true, and wake it up. */
> > > kthread_stop_info.k = k;
> > > + if (!freezer_should_exempt(current)) {
> > > + /* We are freezable, so we must make sure that the thread being
> > > + * stopped is not frozen and will not be frozen until it dies
> > > + */
> > > + freezer_exempt(k);
> > > + if (frozen(k))
> > > + clear_frozen_flag(k);
> > > + }
> >
> > I'm trying hard to convince myself that this will work. May be I am
> > missing something here, but I find a potential race window (very small though)
> > when k is entering the refrigerator.
> >
> > [... snip ... ]
> >
> > IMO, we need the to take the task_lock for k here. Something like
> >
> > > + if (!freezer_should_exempt(current)) {
> > task_lock(k);
> > > + /* We are freezable, so we must make sure that the thread being
> > > + * stopped is not frozen and will not be frozen until it dies
> > > + */
> > > + freezer_exempt(k);
> > > + if (frozen(k))
> > > + clear_frozen_flag(k);
> > task_unlock(k);
> > > + }
>
> Well, probably I missed something, but why can't we do
>
> if (!freezer_should_exempt(current)) {
> freezer_exempt(k);
> thaw_process(k);
> }
> ?
>
> thaw_process(k) is properly serialized with refrigerator(), and it checks
> frozen(k). We can make an extra wake_up, but this should not matter.
Yes, I think you're right.
> Rafael, please check the recent changes in kthread.c, kthread_stop() was
> reworked, we don't have kthread_stop_info any longer.
OK, I will, thanks.
Greetings,
Rafael
-
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