forked from levex/cgroups-rs
-
Notifications
You must be signed in to change notification settings - Fork 58
Open
Description
Title: cpuset effective_cpus/effective_mems use wrong file names for cgroup v2
Description:
The cpuset controller is reading the wrong files for effective CPUs/mems on cgroup v2 systems.
In src/fs/cpuset.rs lines 282 and 288, the code reads:
cpuset.effective_cpuscpuset.effective_mems
However, these file names changed between v1 and v2:
cgroup v1:
cpuset.effective_cpuscpuset.effective_mems
cgroup v2:
cpuset.cpus.effectivecpuset.mems.effective
The current implementation always uses the v1 names even though the controller has a v2 flag. This causes cpuset().effective_cpus to return an empty vector on v2 systems since the file doesn't exist.
Reproduction:
On a system using cgroup v2:
let cg = Cgroup::load(Box::new(V2::new()), PathBuf::from("some/cgroup"));
let cpuset_ctrl: &CpuSetController = cg.controller_of().unwrap();
let cpuset = cpuset_ctrl.cpuset();
// cpuset.effective_cpus will be empty even if CPUs are assignedFix:
The cpuset() method should check self.v2 and use the appropriate file names:
effective_cpus: {
let file = if self.v2 {
"cpuset.cpus.effective"
} else {
"cpuset.effective_cpus"
};
self.open_path(file, false)
.and_then(read_string_from)
.and_then(parse_range)
.unwrap_or_default()
},References:
Metadata
Metadata
Assignees
Labels
No labels