diff --git a/src/blkio.rs b/src/blkio.rs index 5d5c156..77dad2c 100644 --- a/src/blkio.rs +++ b/src/blkio.rs @@ -268,7 +268,7 @@ impl Controller for BlkIoController { } fn apply(&self, res: &Resources) -> Result<(), CgroupError> { - /* get the resources that apply to this controller */ + // get the resources that apply to this controller let res: &BlkIoResources = &res.blkio; if res.update_values { diff --git a/src/cgroup.rs b/src/cgroup.rs index 33260fc..e3a10b2 100644 --- a/src/cgroup.rs +++ b/src/cgroup.rs @@ -121,10 +121,8 @@ impl<'b> Cgroup<'b> { { for i in &self.subsystems { if i.to_controller().control_type() == T::controller_type() { - /* - * N.B.: - * https://play.rust-lang.org/?gist=978b2846bacebdaa00be62374f4f4334&version=stable&mode=debug&edition=2015 - */ + // N.B.: + // https://play.rust-lang.org/?gist=978b2846bacebdaa00be62374f4f4334&version=stable&mode=debug&edition=2015 return Some(i.into()); } } @@ -149,7 +147,7 @@ impl<'b> Cgroup<'b> { /// Returns an Iterator that can be used to iterate over the tasks that are currently in the /// control group. pub fn tasks(&self) -> Vec { - /* Collect the tasks from all subsystems */ + // Collect the tasks from all subsystems let mut v = self .subsystems() .iter() diff --git a/src/cpu.rs b/src/cpu.rs index 6af7b7f..38825bf 100644 --- a/src/cpu.rs +++ b/src/cpu.rs @@ -35,35 +35,41 @@ impl Controller for CpuController { fn control_type(&self) -> Controllers { Controllers::Cpu } + fn get_path(&self) -> &PathBuf { &self.path } + fn get_path_mut(&mut self) -> &mut PathBuf { &mut self.path } + fn get_base(&self) -> &PathBuf { &self.base } fn apply(&self, res: &Resources) -> Result<(), CgroupError> { - /* get the resources that apply to this controller */ + // get the resources that apply to this controller let res: &CpuResources = &res.cpu; if res.update_values { - /* apply pid_max */ + // apply pid_max let _ = self.set_shares(res.shares); if self.shares() != Ok(res.shares as u64) { return Err(CgroupError::Unknown); } + let _ = self.set_cfs_period(res.period); if self.cfs_period() != Ok(res.period as u64) { return Err(CgroupError::Unknown); } + let _ = self.set_cfs_quota(res.quota as u64); if self.cfs_quota() != Ok(res.quota as u64) { return Err(CgroupError::Unknown); } - /* TODO: rt properties (CONFIG_RT_GROUP_SCHED) are not yet supported */ + + // TODO: rt properties (CONFIG_RT_GROUP_SCHED) are not yet supported } Ok(()) diff --git a/src/cpuset.rs b/src/cpuset.rs index 7b6dc7c..786e0aa 100644 --- a/src/cpuset.rs +++ b/src/cpuset.rs @@ -92,7 +92,7 @@ impl Controller for CpuSetController { } fn apply(&self, res: &Resources) -> Result<(), CgroupError> { - /* get the resources that apply to this controller */ + // get the resources that apply to this controller let res: &CpuResources = &res.cpu; if res.update_values { @@ -148,12 +148,12 @@ fn parse_range(s: String) -> Result, CgroupError> { return Ok(fin); } - /* first split by commas */ + // first split by commas let comma_split = s.split(","); for sp in comma_split { if sp.contains("-") { - /* this is a true range */ + // this is a true range let dash_split = sp.split("-").collect::>(); if dash_split.len() != 2 { return Err(CgroupError::ParseError); @@ -165,7 +165,7 @@ fn parse_range(s: String) -> Result, CgroupError> { } fin.push((first.unwrap(), second.unwrap())); } else { - /* this is just a single number */ + // this is just a single number let num = sp.parse::(); if num.is_err() { return Err(CgroupError::ParseError); diff --git a/src/devices.rs b/src/devices.rs index 341a0ae..45dfc7a 100644 --- a/src/devices.rs +++ b/src/devices.rs @@ -143,7 +143,7 @@ impl Controller for DevicesController { } fn apply(&self, res: &Resources) -> Result<(), CgroupError> { - /* get the resources that apply to this controller */ + // get the resources that apply to this controller let res: &DeviceResources = &res.devices; if res.update_values { diff --git a/src/hierarchies.rs b/src/hierarchies.rs index 9f3ebcd..0bdb5f0 100644 --- a/src/hierarchies.rs +++ b/src/hierarchies.rs @@ -109,10 +109,10 @@ impl V1 { } fn find_v1_mount() -> Option { - /* Open mountinfo so we can get a parseable mount list */ + // Open mountinfo so we can get a parseable mount list let mountinfo_path = Path::new("/proc/self/mountinfo"); - /* If /proc isn't mounted, or something else happens, then bail out */ + // If /proc isn't mounted, or something else happens, then bail out if mountinfo_path.exists() == false { return None; } diff --git a/src/hugetlb.rs b/src/hugetlb.rs index 6411205..64e9e39 100644 --- a/src/hugetlb.rs +++ b/src/hugetlb.rs @@ -37,7 +37,7 @@ impl Controller for HugeTlbController { } fn apply(&self, res: &Resources) -> Result<(), CgroupError> { - /* get the resources that apply to this controller */ + // get the resources that apply to this controller let res: &HugePageResources = &res.hugepages; if res.update_values { @@ -93,7 +93,7 @@ impl HugeTlbController { /// Whether the system supports `hugetlb_size` hugepages. pub fn size_supported(&self, _hugetlb_size: String) -> bool { - /* TODO */ + // TODO true } diff --git a/src/lib.rs b/src/lib.rs index f34d370..86f0969 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -143,7 +143,7 @@ pub trait Controller { /// kernel the information. fn apply(&self, res: &Resources) -> Result<(), CgroupError>; - /* meta stuff */ + // meta stuff #[doc(hidden)] fn control_type(&self) -> Controllers; #[doc(hidden)] @@ -302,14 +302,14 @@ pub struct PidResources { pub struct CpuResources { /// Whether values should be applied to the controller. pub update_values: bool, - /* cpuset */ + // cpuset /// A comma-separated list of CPU IDs where the task in the control group can run. Dashes /// between numbers indicate ranges. pub cpus: String, /// Same syntax as the `cpus` field of this structure, but applies to memory nodes instead of /// processors. pub mems: String, - /* cpu */ + // cpu /// Weight of how much of the total CPU time should this control group get. Note that this is /// hierarchical, so this is weighted against the siblings of this control group. pub shares: u64, diff --git a/src/memory.rs b/src/memory.rs index 0c72ecd..98f57c4 100644 --- a/src/memory.rs +++ b/src/memory.rs @@ -325,7 +325,7 @@ pub struct Memory { pub max_usage_in_bytes: u64, /// Whether moving charges at immigrate is allowed. pub move_charge_at_immigrate: u64, - /* TODO: parse this */ + // TODO: parse this /// Contains various statistics about the NUMA locality of the control group's tasks. /// /// The format of this field (as lifted from the kernel sources): @@ -342,7 +342,7 @@ pub struct Memory { /// Allows setting a limit to memory usage which is enforced when the system (note, _not_ the /// control group) detects memory pressure. pub soft_limit_in_bytes: u64, - /* TODO: parse this */ + // TODO: parse this /// Contains a wide array of statistics about the memory usage of the tasks in the control /// group. pub stat: MemoryStat, @@ -406,7 +406,7 @@ impl Controller for MemController { } fn apply(&self, res: &Resources) -> Result<(), CgroupError> { - /* get the resources that apply to this controller */ + // get the resources that apply to this controller let memres: &MemoryResources = &res.memory; if memres.update_values { diff --git a/src/net_cls.rs b/src/net_cls.rs index 2b9234a..0ede9c9 100644 --- a/src/net_cls.rs +++ b/src/net_cls.rs @@ -38,7 +38,7 @@ impl Controller for NetClsController { } fn apply(&self, res: &Resources) -> Result<(), CgroupError> { - /* get the resources that apply to this controller */ + // get the resources that apply to this controller let res: &NetworkResources = &res.network; if res.update_values { diff --git a/src/net_prio.rs b/src/net_prio.rs index 2d126da..096f3d3 100644 --- a/src/net_prio.rs +++ b/src/net_prio.rs @@ -39,7 +39,7 @@ impl Controller for NetPrioController { } fn apply(&self, res: &Resources) -> Result<(), CgroupError> { - /* get the resources that apply to this controller */ + // get the resources that apply to this controller let res: &NetworkResources = &res.network; if res.update_values { diff --git a/src/pid.rs b/src/pid.rs index 3aa21bc..a0a8d34 100644 --- a/src/pid.rs +++ b/src/pid.rs @@ -49,14 +49,14 @@ impl Controller for PidController { } fn apply(&self, res: &Resources) -> Result<(), CgroupError> { - /* get the resources that apply to this controller */ + // get the resources that apply to this controller let pidres: &PidResources = &res.pid; if pidres.update_values { - /* apply pid_max */ + // apply pid_max let _ = self.set_pid_max(pidres.maximum_number_of_processes); - /* now, verify */ + // now, verify if self.get_pid_max() == Ok(pidres.maximum_number_of_processes) { return Ok(()); } else { @@ -68,11 +68,11 @@ impl Controller for PidController { } } -/*impl<'a> ControllIdentifier for &'a PidController { - fn controller_type() -> Controllers { - Controllers::Pids - } -}*/ +// impl<'a> ControllIdentifier for &'a PidController { +// fn controller_type() -> Controllers { +// Controllers::Pids +// } +// } impl ControllIdentifier for PidController { fn controller_type() -> Controllers { diff --git a/tests/resources.rs b/tests/resources.rs index 31021f2..342b541 100644 --- a/tests/resources.rs +++ b/tests/resources.rs @@ -18,7 +18,7 @@ fn pid_resources() { }; cg.apply(&res); - /* verify */ + // verify let pidcontroller: &PidController = cg.controller_of().unwrap(); let pid_max = pidcontroller.get_pid_max(); assert_eq!(pid_max.is_ok(), true);