diff options
author | Tejun Heo <tj@kernel.org> | 2011-11-21 12:32:24 -0800 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2011-11-21 12:32:24 -0800 |
commit | 6907483b4e803a20f0b48cc9afa3817420ce61c5 (patch) | |
tree | 9f4b7cbe59eae0c6f59d704e4f465d537c172479 /kernel/power | |
parent | 0c9af09262864a2744091ee94c98c4a8fd60c98b (diff) | |
download | linux-stable-6907483b4e803a20f0b48cc9afa3817420ce61c5.tar.gz linux-stable-6907483b4e803a20f0b48cc9afa3817420ce61c5.tar.bz2 linux-stable-6907483b4e803a20f0b48cc9afa3817420ce61c5.zip |
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>
Diffstat (limited to 'kernel/power')
-rw-r--r-- | kernel/power/process.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/power/process.c b/kernel/power/process.c index bd420ca48261..e6e2739190b5 100644 --- a/kernel/power/process.c +++ b/kernel/power/process.c @@ -118,7 +118,8 @@ static int try_to_freeze_tasks(bool sig_only) read_lock(&tasklist_lock); do_each_thread(g, p) { - if (!wakeup && freezing(p) && !freezer_should_skip(p)) + if (!wakeup && !freezer_should_skip(p) && + freezing(p) && !frozen(p)) sched_show_task(p); cancel_freezing(p); } while_each_thread(g, p); |