Merge "libprocessgroup: new method to get cgroup paths"

This commit is contained in:
Marco Ballesio 2021-02-25 03:47:01 +00:00 committed by Gerrit Code Review
commit 86f17cce1e
3 changed files with 11 additions and 2 deletions

View file

@ -36,7 +36,8 @@ bool SetProcessProfiles(uid_t uid, pid_t pid, const std::vector<std::string>& pr
static constexpr const char* CGROUPS_RC_PATH = "/dev/cgroup_info/cgroup.rc";
// Path to test against for freezer support
// TODO: remove and replace with a function call, see http://b/180056337
// TODO: remove it once https://r.android.com/1607196 is properly merged to all branches,
// see http://b/180056337
static constexpr const char* CGROUP_FREEZE_PATH = "/sys/fs/cgroup/uid_0/cgroup.freeze";
bool UsePerAppMemcg();
@ -68,6 +69,10 @@ bool setProcessGroupLimit(uid_t uid, int initialPid, int64_t limitInBytes);
void removeAllProcessGroups(void);
// Provides the path for an attribute in a specific process group
// Returns false in case of error, true in case of success
bool getAttributePathForTask(const std::string& attr_name, int tid, std::string* path);
#endif // __ANDROID_VNDK__
__END_DECLS

View file

@ -508,3 +508,7 @@ bool setProcessGroupSoftLimit(uid_t, int pid, int64_t soft_limit_in_bytes) {
bool setProcessGroupLimit(uid_t, int pid, int64_t limit_in_bytes) {
return SetProcessGroupValue(pid, "MemLimit", limit_in_bytes);
}
bool getAttributePathForTask(const std::string& attr_name, int tid, std::string* path) {
return CgroupGetAttributePathForTask(attr_name, tid, path);
}

View file

@ -37,7 +37,7 @@
"Controllers": [
{
"Controller": "freezer",
"Path": "freezer",
"Path": ".",
"Mode": "0755",
"UID": "system",
"GID": "system"