Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b1db5922 authored by Suren Baghdasaryan's avatar Suren Baghdasaryan
Browse files

rootdir: Add cgroups and task profiles description files



Add cgroups.json and task_profiles.json file to be places under /etc/ on
the device to describe cgroups to be mounted and task profiles that
processes can request. This adds additional layer of abstraction between
what a process wants to achieve and how system implements that request.

Bug: 111307099
test: builds, boots

Change-Id: If92f011230ef5d24750e184bad776f30ba226f86
Signed-off-by: default avatarSuren Baghdasaryan <surenb@google.com>
parent 9f9886e1
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -46,6 +46,28 @@ LOCAL_POST_INSTALL_CMD += ; ln -sf /apex/com.android.runtime/etc/icu $(TARGET_OU

include $(BUILD_PREBUILT)

#######################################
# cgroups.json
include $(CLEAR_VARS)

LOCAL_MODULE := cgroups.json
LOCAL_SRC_FILES := $(LOCAL_MODULE)
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)

include $(BUILD_PREBUILT)

#######################################
# task_profiles.json
include $(CLEAR_VARS)

LOCAL_MODULE := task_profiles.json
LOCAL_SRC_FILES := $(LOCAL_MODULE)
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)

include $(BUILD_PREBUILT)

#######################################
# asan.options
ifneq ($(filter address,$(SANITIZE_TARGET)),)

rootdir/cgroups.json

0 → 100644
+43 −0
Original line number Diff line number Diff line
{
  "Cgroups": [
    {
      "Controller": "cpu",
      "Path": "/dev/cpuctl",
      "Mode": 0755,
      "UID": "system",
      "GID": "system"
    },
    {
      "Controller": "cpuacct",
      "Path": "/acct",
      "Mode": 0555
    },
    {
      "Controller": "cpuset",
      "Path": "/dev/cpuset",
      "Mode": 0755,
      "UID": "system",
      "GID": "system"
    },
    {
      "Controller": "memory",
      "Path": "/dev/memcg",
      "Mode": 0700,
      "UID": "root",
      "GID": "system"
    },
    {
      "Controller": "schedtune",
      "Path": "/dev/stune",
      "Mode": 0755,
      "UID": "system",
      "GID": "system"
    }
  ],
  "Cgroups2": {
    "Path": "/dev/cg2_bpf",
    "Mode": 0600,
    "UID": "root",
    "GID": "root"
  }
}
+445 −0
Original line number Diff line number Diff line
{
  "Attributes": [
    {
      "Name": "LowCapacityCPUs",
      "Controller": "cpuset",
      "File": "background/cpus"
    },
    {
      "Name": "HighCapacityCPUs",
      "Controller": "cpuset",
      "File": "foreground/cpus"
    },
    {
      "Name": "MaxCapacityCPUs",
      "Controller": "cpuset",
      "File": "top-app/cpus"
    },

    {
      "Name": "MemLimit",
      "Controller": "memory",
      "File": "memory.limit_in_bytes"
    },
    {
      "Name": "MemSoftLimit",
      "Controller": "memory",
      "File": "memory.soft_limit_in_bytes"
    },
    {
      "Name": "MemSwappiness",
      "Controller": "memory",
      "File": "memory.swappiness"
    },
    {
      "Name": "STuneBoost",
      "Controller": "schedtune",
      "File": "schedtune.boost"
    },
    {
      "Name": "STunePreferIdle",
      "Controller": "schedtune",
      "File": "schedtune.prefer_idle"
    },
    {
      "Name": "UClampMin",
      "Controller": "cpu",
      "File": "cpu.util.min"
    },
    {
      "Name": "UClampMax",
      "Controller": "cpu",
      "File": "cpu.util.max"
    }
  ],

  "Profiles": [
    {
      "Name": "HighEnergySaving",
      "Actions" : [
        {
          "Name" : "JoinCgroup",
          "Params" :
          {
            "Controller": "schedtune",
            "Path": "background"
          }
        }
      ]
    },
    {
      "Name": "NormalPerformance",
      "Actions" : [
        {
          "Name" : "JoinCgroup",
          "Params" :
          {
            "Controller": "schedtune",
            "Path": ""
          }
        }
      ]
    },
    {
      "Name": "HighPerformance",
      "Actions" : [
        {
          "Name" : "JoinCgroup",
          "Params" :
          {
            "Controller": "schedtune",
            "Path": "foreground"
          }
        }
      ]
    },
    {
      "Name": "MaxPerformance",
      "Actions" : [
        {
          "Name" : "JoinCgroup",
          "Params" :
          {
            "Controller": "schedtune",
            "Path": "top-app"
          }
        }
      ]
    },
    {
      "Name": "RealtimePerformance",
      "Actions" : [
        {
          "Name" : "JoinCgroup",
          "Params" :
          {
            "Controller": "schedtune",
            "Path": "rt"
          }
        }
      ]
    },

    {
      "Name": "CpuPolicySpread",
      "Actions" : [
        {
          "Name" : "SetAttribute",
          "Params" :
          {
            "Name" : "STunePreferIdle",
            "Value" : "1"
          }
        }
      ]
    },
    {
      "Name": "CpuPolicyPack",
      "Actions" : [
        {
          "Name" : "SetAttribute",
          "Params" :
          {
            "Name" : "STunePreferIdle",
            "Value" : "0"
          }
        }
      ]
    },

    {
      "Name": "VrKernelCapacity",
      "Actions" : [
        {
          "Name" : "JoinCgroup",
          "Params" :
          {
            "Controller": "cpuset",
            "Path": ""
          }
        }
      ]
    },
    {
      "Name": "VrServiceCapacityLow",
      "Actions" : [
        {
          "Name" : "JoinCgroup",
          "Params" :
          {
            "Controller": "cpuset",
            "Path": "system/background"
          }
        }
      ]
    },
    {
      "Name": "VrServiceCapacityNormal",
      "Actions" : [
        {
          "Name" : "JoinCgroup",
          "Params" :
          {
            "Controller": "cpuset",
            "Path": "system"
          }
        }
      ]
    },
    {
      "Name": "VrServiceCapacityHigh",
      "Actions" : [
        {
          "Name" : "JoinCgroup",
          "Params" :
          {
            "Controller": "cpuset",
            "Path": "system/performance"
          }
        }
      ]
    },
    {
      "Name": "VrProcessCapacityLow",
      "Actions" : [
        {
          "Name" : "JoinCgroup",
          "Params" :
          {
            "Controller": "cpuset",
            "Path": "application/background"
          }
        }
      ]
    },
    {
      "Name": "VrProcessCapacityNormal",
      "Actions" : [
        {
          "Name" : "JoinCgroup",
          "Params" :
          {
            "Controller": "cpuset",
            "Path": "application"
          }
        }
      ]
    },
    {
      "Name": "VrProcessCapacityHigh",
      "Actions" : [
        {
          "Name" : "JoinCgroup",
          "Params" :
          {
            "Controller": "cpuset",
            "Path": "application/performance"
          }
        }
      ]
    },

    {
      "Name": "ProcessCapacityLow",
      "Actions" : [
        {
          "Name" : "JoinCgroup",
          "Params" :
          {
            "Controller": "cpuset",
            "Path": "background"
          }
        }
      ]
    },
    {
      "Name": "ProcessCapacityNormal",
      "Actions" : [
        {
          "Name" : "JoinCgroup",
          "Params" :
          {
            "Controller": "cpuset",
            "Path": ""
          }
        }
      ]
    },
    {
      "Name": "ProcessCapacityHigh",
      "Actions" : [
        {
          "Name" : "JoinCgroup",
          "Params" :
          {
            "Controller": "cpuset",
            "Path": "foreground"
          }
        }
      ]
    },
    {
      "Name": "ProcessCapacityMax",
      "Actions" : [
        {
          "Name" : "JoinCgroup",
          "Params" :
          {
            "Controller": "cpuset",
            "Path": "top-app"
          }
        }
      ]
    },

    {
      "Name": "ServiceCapacityLow",
      "Actions" : [
        {
          "Name" : "JoinCgroup",
          "Params" :
          {
            "Controller": "cpuset",
            "Path": "system-background"
          }
        }
      ]
    },
    {
      "Name": "ServiceCapacityRestricted",
      "Actions" : [
        {
          "Name" : "JoinCgroup",
          "Params" :
          {
            "Controller": "cpuset",
            "Path": "restricted"
          }
        }
      ]
    },

    {
      "Name": "CameraServiceCapacity",
      "Actions" : [
        {
          "Name" : "JoinCgroup",
          "Params" :
          {
            "Controller": "cpuset",
            "Path": "camera-daemon"
          }
        }
      ]
    },

    {
      "Name": "TimerSlackHigh",
      "Actions" : [
        {
          "Name" : "SetTimerSlack",
          "Params" :
          {
            "Slack": "40000000"
          }
        }
      ]
    },
    {
      "Name": "TimerSlackNormal",
      "Actions" : [
        {
          "Name" : "SetTimerSlack",
          "Params" :
          {
            "Slack": "50000"
          }
        }
      ]
    },

    {
      "Name": "PerfBoost",
      "Actions" : [
        {
          "Name" : "SetClamps",
          "Params" :
          {
            "Boost" : "50%",
            "Clamp" : "0"
          }
        }
      ]
    },
    {
      "Name": "PerfClamp",
      "Actions" : [
        {
          "Name" : "SetClamps",
          "Params" :
          {
            "Boost" : "0",
            "Clamp" : "30%"
          }
        }
      ]
    },

    {
      "Name": "LowMemoryUsage",
      "Actions" : [
        {
          "Name" : "SetAttribute",
          "Params" :
          {
            "Name" : "MemSoftLimit",
            "Value" : "16MB"
          }
        },
        {
          "Name" : "SetAttribute",
          "Params" :
          {
            "Name" : "MemSwappiness",
            "Value" : "150"

          }
        }
      ]
    },
    {
      "Name": "HighMemoryUsage",
      "Actions" : [
        {
          "Name" : "SetAttribute",
          "Params" :
          {
            "Name" : "MemSoftLimit",
            "Value" : "512MB"
          }
        },
        {
          "Name" : "SetAttribute",
          "Params" :
          {
            "Name" : "MemSwappiness",
            "Value" : "100"
          }
        }
      ]
    },
    {
      "Name": "SystemMemoryProcess",
      "Actions" : [
        {
          "Name" : "JoinCgroup",
          "Params" :
          {
            "Controller": "memory",
            "Path": "system"
          }
        }
      ]
    }
  ]
}