]> git.karo-electronics.de Git - karo-tx-linux.git/commit
freezer: make freezing() test freeze conditions in effect instead of TIF_FREEZE
authorTejun Heo <tj@kernel.org>
Thu, 3 Nov 2011 22:19:27 +0000 (15:19 -0700)
committerTejun Heo <tj@kernel.org>
Thu, 3 Nov 2011 22:19:27 +0000 (15:19 -0700)
commit3b6a8586712c3bb939c4ee9197cfa12a2bb70ac7
tree1d380c2a612f6518e1fbbdc5ac521f6fa7291378
parentbf9d5d3d1651f61dd51a4dca513d55e83b40f1b2
freezer: make freezing() test freeze conditions in effect instead of TIF_FREEZE

Using TIF_FREEZE for freezing worked when there was only single
freezing condition (the PM one); however, now there is also the
cgroup_freezer and single bit flag is getting clumsy.
thaw_processes() is already testing whether cgroup freezing in in
effect to avoid thawing tasks which were frozen by both PM and cgroup
freezers.

This is racy (nothing prevents race against cgroup freezing) and
fragile.  A much simpler way is to test actual freeze conditions from
freezing() - ie. directly test whether PM or cgroup freezing is in
effect.

This patch adds variables to indicate whether and what type of
freezing conditions are in effect and reimplements freezing() such
that it directly tests whether any of the two freezing conditions is
active and the task should freeze.  On fast path, freezing() is still
very cheap - it only tests system_freezing_cnt.

This makes the clumsy dancing aroung TIF_FREEZE unnecessary and
freeze/thaw operations more usual - updating state variables for the
new state and nudging target tasks so that they notice the new state
and comply.  As long as the nudging happens after state update, it's
race-free.

* This allows use of freezing() in freeze_task().  Replace the open
  coded tests with freezing().

* p != current test is added to warning printing conditions in
  try_to_freeze_tasks() failure path.  This is necessary as freezing()
  is now true for the task which initiated freezing too.

-v2: Oleg pointed out that re-freezing FROZEN cgroup could increment
     system_freezing_cnt.  Fixed.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Paul Menage <paul@paulmenage.org> (for the cgroup portions)
include/linux/freezer.h
kernel/cgroup_freezer.c
kernel/fork.c
kernel/freezer.c
kernel/power/process.c