]> git.karo-electronics.de Git - karo-tx-linux.git/commit
freezer: fix set_freezable[_with_signal]() race
authorTejun Heo <tj@kernel.org>
Sat, 20 Aug 2011 09:31:40 +0000 (11:31 +0200)
committerTejun Heo <tj@kernel.org>
Sat, 20 Aug 2011 09:31:40 +0000 (11:31 +0200)
commit6d30dc9124e0b086d66f051c7f55c89dfc10fc50
treeeecc973a25aa345c3e753f8038a8cdf22bd7afe4
parentc4adb5122ab674d3572b04b1cebaf2b2f46cfc26
freezer: fix set_freezable[_with_signal]() race

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 merrily proceeding to execute code paths which aren't
supposed to be executing during PM freeze.

This can be fixed by modifying and testing the related PF flags inside
freezer_lock and removing mostly unnecessary early tests from the
callers of freeze/thaw_task().

* Remove all unnecessary tests from kerne/power/process.c and add
  PF_NOFREEZE test to freeze_task(), which is meaningful as it avoids
  sending unsolicited wakeups to nofreeze tasks.

* Reimplement set_freezable[_with_signal]() using __set_freezable()
  such that freezable PF flags are modified under freezer_lock and
  try_to_freeze() is called afterwards.  Combined with the above
  change, this eliminates race condition against freezing.

Signed-off-by: Tejun Heo <tj@kernel.org>
include/linux/freezer.h
kernel/freezer.c
kernel/power/process.c