This reverts commit
39012eeefa454e09fc4192cacddb508ee00abee6.
As per the no internal process constraint, of cgroup v2 no controller
should be enabled in the leaf cgroup node. This patch breaks this
constraint by assuming the controllers are enabled until the leaf node
of the hierarchy. Let's revert to the original approach of reading
until the parent of the leaf cgroup node.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit
59dff6c981b79ab5e92179e187fc065c53aef54f)
STATIC int cgroupv2_controller_enabled(const char * const cg_name, const char * const ctrl_name)
{
char path[FILENAME_MAX] = {0};
+ char *parent = NULL, *dname;
enum cg_version_t version;
bool enabled;
int error;
if (!cg_build_path(cg_name, path, ctrl_name))
goto err;
- error = cgroupv2_get_subtree_control(path, ctrl_name, &enabled);
+ parent = strdup(path);
+ if (!parent) {
+ error = ECGOTHER;
+ goto err;
+ }
+
+ dname = dirname(parent);
+
+ error = cgroupv2_get_subtree_control(dname, ctrl_name, &enabled);
if (error)
goto err;
if (enabled)
error = 0;
err:
+ if (parent)
+ free(parent);
+
return error;
}