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

Commit 3d54c32e authored by T.J. Mercier's avatar T.J. Mercier Committed by Gerrit Code Review
Browse files

Merge "libprocessgroup: Add MaxActivationDepth" into main

parents 969888c1 28b37f27
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ cc_library {
    header_libs: [
        "libcutils_headers",
        "libprocessgroup_headers",
        "libprocessgroup_util",
    ],
    export_include_dirs: ["include"],
    export_header_lib_headers: [
+8 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include <android-base/strings.h>
#include <cgroup_map.h>
#include <processgroup/processgroup.h>
#include <processgroup/util.h>

using android::base::StartsWith;
using android::base::StringPrintf;
@@ -216,7 +217,13 @@ int CgroupMap::ActivateControllers(const std::string& path) const {
        for (uint32_t i = 0; i < controller_count; ++i) {
            const ACgroupController* controller = ACgroupFile_getController(i);
            const uint32_t flags = ACgroupController_getFlags(controller);
            if (flags & CGROUPRC_CONTROLLER_FLAG_NEEDS_ACTIVATION) {
            uint32_t max_activation_depth = UINT32_MAX;
            if (__builtin_available(android 36, *)) {
                max_activation_depth = ACgroupController_getMaxActivationDepth(controller);
            }
            const int depth = util::GetCgroupDepth(ACgroupController_getPath(controller), path);

            if (flags & CGROUPRC_CONTROLLER_FLAG_NEEDS_ACTIVATION && depth < max_activation_depth) {
                std::string str("+");
                str.append(ACgroupController_getName(controller));
                if (!WriteStringToFile(str, path + "/cgroup.subtree_control")) {
+5 −0
Original line number Diff line number Diff line
@@ -32,6 +32,11 @@ uint32_t ACgroupController_getFlags(const ACgroupController* controller) {
    return controller->flags();
}

uint32_t ACgroupController_getMaxActivationDepth(const ACgroupController* controller) {
    CHECK(controller != nullptr);
    return controller->max_activation_depth();
}

const char* ACgroupController_getName(const ACgroupController* controller) {
    CHECK(controller != nullptr);
    return controller->name();
+8 −0
Original line number Diff line number Diff line
@@ -78,6 +78,14 @@ __attribute__((warn_unused_result)) uint32_t ACgroupController_getVersion(const
__attribute__((warn_unused_result, weak)) uint32_t ACgroupController_getFlags(
        const ACgroupController*) __INTRODUCED_IN(30);

/**
 * Returns the maximum activation depth of the given controller.
 * Only applicable to cgroup v2 controllers.
 * Returns UINT32_MAX if no maximum activation depth is set.
 */
__attribute__((warn_unused_result, weak)) uint32_t ACgroupController_getMaxActivationDepth(
        const ACgroupController* controller) __INTRODUCED_IN(36);

/**
 * Returns the name of the given controller.
 * If the given controller is null, return nullptr.
+7 −0
Original line number Diff line number Diff line
@@ -16,3 +16,10 @@ LIBCGROUPRC_30 { # introduced=30
  local:
    *;
};

LIBCGROUPRC_36 { # introduced=36
  global:
    ACgroupController_getMaxActivationDepth; # llndk=202504 systemapi
  local:
    *;
};
Loading