| Date | Sun, 21 Aug 2011 21:14:21 +0200 | From | Oleg Nesterov <> | Subject | Re: [PATCH 04/16] freezer: implement and use kthread_freezable_should_stop() |
| |
On 08/19, Tejun Heo wrote: > > +bool kthread_freezable_should_stop(bool *was_frozen) > +{ > + bool frozen = false; > + > + might_sleep(); > + > + if (unlikely(freezing(current))) > + frozen = __refrigerator(true); > + > + if (was_frozen) > + *was_frozen = frozen; > + > + return kthread_should_stop(); > +}
Imho, nice interface...
So, the caller can not miss the kthread_stop() request and freeze. And the change in __refrigerator() means that kthread_should_stop() acts as thaw_process() (in some sense).
But. can't __refrigerator() race with thaw_process() in this case?
> +bool __refrigerator(bool check_kthr_stop) > { > /* Hmm, should we be allowed to suspend when there are realtime > processes around? */ > @@ -50,7 +51,8 @@ bool __refrigerator(void) > > for (;;) { > set_current_state(TASK_UNINTERRUPTIBLE); > - if (!frozen(current)) > + if (!frozen(current) || > + (check_kthr_stop && kthread_should_stop())) > break;
OK, but then we do
current->flags &= ~PF_FREEZING;
since PF_FROZEN wasn't cleared this can race with
p->flags &= ~PF_FROZEN;
No?
Oleg.
|