From 726a68cb401538da8843ee3521e7bd8f81823e48 Mon Sep 17 00:00:00 2001 From: Marco Ballesio Date: Tue, 8 Oct 2019 09:12:22 -0700 Subject: [PATCH] Add support for freezer cgroup Adds the freezer cgroup to process groups Change-Id: Ib7a8dbe776ff156ff3827b9a659365384f3e6ac8 Bug: 143308662 Test: manual - frozen processes aren't scheduled for execution until unfrozen --- libprocessgroup/profiles/cgroups.json | 7 ++++++ libprocessgroup/profiles/task_profiles.json | 26 +++++++++++++++++++++ rootdir/init.rc | 10 ++++++++ 3 files changed, 43 insertions(+) diff --git a/libprocessgroup/profiles/cgroups.json b/libprocessgroup/profiles/cgroups.json index 5871a63fa..03419020c 100644 --- a/libprocessgroup/profiles/cgroups.json +++ b/libprocessgroup/profiles/cgroups.json @@ -39,6 +39,13 @@ "Mode": "0755", "UID": "system", "GID": "system" + }, + { + "Controller": "freezer", + "Path": "/dev/freezer", + "Mode": "0755", + "UID": "system", + "GID": "system" } ], "Cgroups2": { diff --git a/libprocessgroup/profiles/task_profiles.json b/libprocessgroup/profiles/task_profiles.json index 608f0071e..3f3dbd72d 100644 --- a/libprocessgroup/profiles/task_profiles.json +++ b/libprocessgroup/profiles/task_profiles.json @@ -66,6 +66,32 @@ } ] }, + { + "Name": "Frozen", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "freezer", + "Path": "frozen" + } + } + ] + }, + { + "Name": "Unfrozen", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "freezer", + "Path": "" + } + } + ] + }, { "Name": "NormalPerformance", "Actions": [ diff --git a/rootdir/init.rc b/rootdir/init.rc index bc18e2746..674b7372d 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc @@ -283,6 +283,16 @@ on init chmod 0664 /dev/cpuset/restricted/tasks chmod 0664 /dev/cpuset/tasks + # freezer cgroup entries + mkdir /dev/freezer/frozen + write /dev/freezer/frozen/freezer.state FROZEN + chown system system /dev/freezer/cgroup.procs + chown system system /dev/freezer/frozen + chown system system /dev/freezer/frozen/freezer.state + chown system system /dev/freezer/frozen/cgroup.procs + + chmod 0444 /dev/freezer/frozen/freezer.state + # make the PSI monitor accessible to others chown system system /proc/pressure/memory chmod 0664 /proc/pressure/memory