agent: Ensure proper cgroupsV2 with init_mode=yes

When the agent is run as the init process cgroupfs is being
setup. In the case of cgroupsV1 we needed to enable the memory hiearchy
this is now per default enabled in cgroupsV2. Additionally the file
/sys/fs/cgroup/memory/memory.use_hierarchy isn't even available with V2.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
This commit is contained in:
Zvonko Kaiser
2025-01-22 21:54:47 +00:00
parent 61c282c725
commit afd286f6d6

View File

@@ -299,7 +299,13 @@ pub fn cgroups_mount(logger: &Logger, unified_cgroup_hierarchy: bool) -> Result<
// Enable memory hierarchical account.
// For more information see https://www.kernel.org/doc/Documentation/cgroup-v1/memory.txt
online_device("/sys/fs/cgroup/memory/memory.use_hierarchy")
// cgroupsV2 will automatically enable memory.use_hierarchy.
// additinoally this directory layout is not present in cgroupsV2.
if !unified_cgroup_hierarchy {
return online_device("/sys/fs/cgroup/memory/memory.use_hierarchy");
}
Ok(())
}
#[instrument]