Re: [PATCH 14/16] freezer: make freezing() test freeze conditionsin effect instead of TIF_FREEZE

From: Oleg Nesterov
Date: Mon Aug 29 2011 - 11:53:14 EST


On 08/19, Tejun Heo wrote:
>
> @@ -311,9 +315,11 @@ static int freezer_change_state(struct cgroup *cgroup,
>
> switch (goal_state) {
> case CGROUP_THAWED:
> + atomic_dec(&system_freezing_cnt);
> unfreeze_cgroup(cgroup, freezer);
> break;
> case CGROUP_FROZEN:
> + atomic_inc(&system_freezing_cnt);

This is harmless, but afaics is not exactly right. CGROUP_FROZEN doesn't
need system_freezing_cnt != 0, everything is already frozen and we just
provoke freezing_slow_path() without any reason. Right?


> @@ -120,13 +120,18 @@ int freeze_processes(void)
> {
> int error;
>
> + if (!pm_freezing)
> + atomic_inc(&system_freezing_cnt);
> +
> printk("Freezing user space processes ... ");
> + pm_freezing = true;

and

> @@ -146,6 +151,11 @@ void thaw_processes(void)
> {
> struct task_struct *g, *p;
>
> + if (pm_freezing)
> + atomic_dec(&system_freezing_cnt);
> + pm_freezing = false;

I simply can't understand this... Why freeze_processes/thaw_processes
check pm_freezing?

IIUC, the calls to freeze/thaw should be serialized anyway (probably
pm_mutex ?). Otherwise this check can't help anyway. Say, _if_ it
is possible to call freeze_processes() with pm_freezing == T, then
the failure path or subsequent thaw_processes() will do the unbalanced
atomic_dec().

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/