Re: [PATCH 04/16] freezer: implement and usekthread_freezable_should_stop()
From: Oleg Nesterov
Date: Sun Aug 21 2011 - 15:23:59 EST
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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/