Re: [PATCH 10/16] freezer: fix set_freezable[_with_signal]() race

From: Oleg Nesterov
Date: Sun Aug 28 2011 - 14:04:45 EST


On 08/19, Tejun Heo wrote:
>
> A kthread doing set_freezable*() may race with on-going PM freeze and
> the freezer might think all tasks are frozen while the new freezable
> kthread is marrily proceeding to execute code paths which aren't
> supposed to be executing during PM freeze.

Yes,

> +bool __set_freezable(bool with_signal)
> +{
> + might_sleep();
> +
> + /*
> + * Modify flags while holding freezer_lock. This ensures the
> + * freezer notices that we aren't frozen yet or the freezing
> + * condition is visible to try_to_freeze() below.
> + */
> + spin_lock_irq(&freezer_lock);
> + current->flags &= ~PF_NOFREEZE;
> + if (with_signal)
> + current->flags &= ~PF_FREEZER_NOSIG;
> + spin_unlock_irq(&freezer_lock);
> +
> + return try_to_freeze();
> +}

You know, I was really, really puzzled by this change. Because it
"obviously can fix nothing", and try_to_freeze() makes no sense
(ignoring the very unlikely case when TIF_FREEZING was set right
after we drop freezer_lock).

But I guess this works along with 14/16 which removes TIF_FREEZING.

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/