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

Commit 73b1659a authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "libprocessgroup: Add CgroupGetAttributePathForProcess and CgroupProcs...

Merge "libprocessgroup: Add CgroupGetAttributePathForProcess and CgroupProcs attribute" into main am: 6ddb8684

Original change: https://android-review.googlesource.com/c/platform/system/core/+/3403426



Change-Id: I7ade699aaa0a614f85362fbd0f5ded1d543b2cc9
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 468d2010 6ddb8684
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@ bool CgroupGetAttributePath(const std::string& attr_name, std::string* path);
// Provides the path for an attribute in a specific process group
// Returns false in case of error, true in case of success
bool CgroupGetAttributePathForTask(const std::string& attr_name, pid_t tid, std::string* path);
bool CgroupGetAttributePathForProcess(std::string_view attr_name, uid_t uid, pid_t pid,
                                      std::string &path);

bool SetTaskProfiles(pid_t tid, const std::vector<std::string>& profiles,
                     bool use_fd_cache = false);
+17 −0
Original line number Diff line number Diff line
@@ -154,6 +154,23 @@ bool CgroupGetAttributePathForTask(const std::string& attr_name, pid_t tid, std:
    return true;
}

bool CgroupGetAttributePathForProcess(std::string_view attr_name, uid_t uid, pid_t pid,
                                      std::string &path) {
    const TaskProfiles& tp = TaskProfiles::GetInstance();
    const IProfileAttribute* attr = tp.GetAttribute(attr_name);

    if (attr == nullptr) {
        return false;
    }

    if (!attr->GetPathForProcess(uid, pid, &path)) {
        LOG(ERROR) << "Failed to find cgroup for uid " << uid << " pid " << pid;
        return false;
    }

    return true;
}

bool UsePerAppMemcg() {
    bool low_ram_device = GetBoolProperty("ro.config.low_ram", false);
    return GetBoolProperty("ro.config.per_app_memcg", low_ram_device);
+5 −0
Original line number Diff line number Diff line
@@ -81,6 +81,11 @@
      "Name": "FreezerState",
      "Controller": "freezer",
      "File": "cgroup.freeze"
    },
    {
      "Name": "CgroupProcs",
      "Controller": "cgroup2",
      "File": "cgroup.procs"
    }
  ],