]> git.karo-electronics.de Git - karo-tx-linux.git/commit
freezer: make freezing indicate freeze condition in effect
authorTejun Heo <tj@kernel.org>
Mon, 31 Oct 2011 22:30:30 +0000 (15:30 -0700)
committerTejun Heo <tj@kernel.org>
Mon, 31 Oct 2011 22:30:30 +0000 (15:30 -0700)
commit0a2769bc117e601488d2290e9a782838401a0956
tree94742fb7b15d596c31a170dd03d87884b3c66bff
parent5272c4231e2e6f10d48d454bda8923dfe170c10a
freezer: make freezing indicate freeze condition in effect

Currently freezing (TIF_FREEZE) and frozen (PF_FROZEN) states are
interlocked - freezing is set to request freeze and when the task
actually freezes, it clears freezing and sets frozen.

This interlocking makes things more complex than necessary - freezing
doesn't mean there's freezing condition in effect and frozen doesn't
match the task actually entering and leaving frozen state (it's
cleared by the thawing task).

This patch makes freezing indicate that freeze condition is in effect.
A task enters and stays frozen if freezing.  This makes PF_FROZEN
manipulation done only by the task itself and prevents wakeup from
__thaw_task() leaking outside of refrigerator.

The only place which needs to tell freezing && !frozen is
try_to_freeze_task() to whine about tasks which don't enter frozen.
It's updated to test the condition explicitly.

With the change, frozen() state my linger after __thaw_task() until
the task wakes up and exits fridge.  This can trigger BUG_ON() in
update_if_frozen().  Work it around by testing freezing() && frozen()
instead of frozen().

-v2: Oleg pointed out missing re-check of freezing() when trying to
     clear FROZEN and possible spurious BUG_ON() trigger in
     update_if_frozen().  Both fixed.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Paul Menage <paul@paulmenage.org>
kernel/cgroup_freezer.c
kernel/freezer.c
kernel/power/process.c