add systemd controller; add more tests; update blkio stat for v2

Signed-off-by: bin liu <bin@hyper.sh>
This commit is contained in:
bin liu
2020-09-04 22:42:49 +08:00
parent c623dc3fba
commit cd2c748a74
19 changed files with 622 additions and 159 deletions

View File

@@ -61,7 +61,6 @@ impl ControllerInternal for CpuController {
let res: &CpuResources = &res.cpu;
if res.update_values {
// apply pid_max
let _ = self.set_shares(res.shares);
if self.shares()? != res.shares as u64 {
return Err(Error::new(ErrorKind::Other));
@@ -163,7 +162,11 @@ impl CpuController {
/// Retrieve the CPU bandwidth that this control group (relative to other control groups and
/// this control group's parent) can use.
pub fn shares(&self) -> Result<u64> {
self.open_path("cpu.shares", false).and_then(read_u64_from)
let mut file = "cpu.shares";
if self.v2 {
file = "cpu.weight";
}
self.open_path(file, false).and_then(read_u64_from)
}
/// Specify a period (when using the CFS scheduler) of time in microseconds for how often this