prplOS: procd: LCM: Add patch to fix cpuset clone_children

Set clone_children flag in cpuset, so it inherits the configured defaults of the parent.

Signed-off-by: Matthias FRANCK <matthias.franck_ext@softathome.com>
(cherry picked from commit 58da6b91b3208438d561638618abb2703c230d0b)
This commit is contained in:
Matthias FRANCK 2022-03-23 13:41:51 +01:00 committed by Petr Štetiar
parent 85dabba53d
commit 978f15f78d
No known key found for this signature in database
GPG Key ID: 58EE120F30CC02D3

View File

@ -0,0 +1,41 @@
--- a/initd/early.c
+++ b/initd/early.c
@@ -29,6 +29,7 @@
#define PATH_CGROUP "/sys/fs/cgroup"
#define PATH_PROC_CGROUPS "/proc/cgroups"
+#define PATH_CPUSET_CLONE_CHILDREN "/cpuset/cgroup.clone_children"
static void
early_dev(void)
@@ -87,6 +88,22 @@ mount_cgroup_controllers(void){
}
static void
+init_cpuset(void){
+ FILE *filp_cpuset = fopen(PATH_CGROUP PATH_CPUSET_CLONE_CHILDREN, "w");
+ if(! filp_cpuset){
+ ERROR("Cannot set " PATH_CPUSET_CLONE_CHILDREN);
+ return;
+ }
+
+ // enable so children copy settings parent
+ // cpuset needs to be populated before this cgroup can be used
+ if( fputs("1", filp_cpuset) < 0){
+ ERROR("Cannot write to " PATH_CPUSET_CLONE_CHILDREN);
+ }
+ fclose(filp_cpuset);
+}
+
+static void
early_mounts(void)
{
unsigned int oldumask = umask(0);
@@ -97,6 +114,7 @@ early_mounts(void)
LOG("Attempting to mount cgroups (tmpfs + controller subdirs)\n");
mount("cgroup2", PATH_CGROUP, "tmpfs", MS_NODEV | MS_NOEXEC | MS_NOSUID, "size=512K");
mount_cgroup_controllers();
+ init_cpuset();
mount("tmpfs", "/dev", "tmpfs", MS_NOATIME | MS_NOEXEC | MS_NOSUID, "mode=0755,size=512K");
ignore(symlink("/tmp/shm", "/dev/shm"));
mkdir("/dev/pts", 0755);