Freezer subsystem is used to manage batch jobs which can startstop at the same time. However, sometime it is desirable to letthe kernel manage the freezer state automatically with a givenduty ratio.For example, if we want to reduce the time that backgroup appsare allowed to run we can put them into a freezer subsystem andset the kernel to turn them THAWED/FROZEN at given duty ratio.

This patch introduces two file nodes under cgroupfreezer.duty_ratio_pct and freezer.period_sec

diff --git a/Documentation/cgroups/freezer-subsystem.txt b/Documentation/cgroups/freezer-subsystem.txtindex 41f37fe..7f06f05 100644--- a/Documentation/cgroups/freezer-subsystem.txt+++ b/Documentation/cgroups/freezer-subsystem.txt@@ -100,3 +100,26 @@ things happens: and returns EINVAL) 3) The tasks that blocked the cgroup from entering the "FROZEN" state disappear from the cgroup's set of tasks.++In embedded systems, it is desirable to manage group of applications+for power saving. E.g. tasks that are not in the foreground may be+frozen unfrozen periodically to save power without affecting user+experience. In this case, user/management software can attach tasks+into freezer cgroup then specify duty ratio and period that the+managed tasks are allowed to run.++Usage example:+Assuming freezer cgroup is already mounted, application being managed+are included the "tasks" file node of the given freezer cgroup.+To make the tasks frozen at 90% of the time every 5 seconds, do:++[root@localhost ]# echo 90 > freezer.duty_ratio_pct+[root@localhost ]# echo 5000 > freezer.period_ms++After that, the application in this freezer cgroup will only be+allowed to run at the following pattern.+ __ __ __+ | |<-- 90% frozen -->| | | |+____| |__________________| |__________________| |_____++ |<---- 5 seconds ---->|diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.cindex e7bebb7..b1c5d19 100644--- a/kernel/cgroup_freezer.c+++ b/kernel/cgroup_freezer.c@@ -21,6 +21,7 @@ #include <linux/uaccess.h> #include <linux/freezer.h> #include <linux/seq_file.h>+#include <linux/kthread.h>