mirror of
https://github.com/kata-containers/cgroups-rs.git
synced 2026-08-05 02:13:23 +00:00
Replace '/*' style comments with '//' style, which is recommended officially
This commit is contained in:
committed by
Levente Kurusa
parent
ffd4cd70e2
commit
adc3323be4
@@ -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 {
|
||||
|
||||
@@ -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<CgroupPid> {
|
||||
/* Collect the tasks from all subsystems */
|
||||
// Collect the tasks from all subsystems
|
||||
let mut v = self
|
||||
.subsystems()
|
||||
.iter()
|
||||
|
||||
12
src/cpu.rs
12
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(())
|
||||
|
||||
@@ -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<Vec<(u64, u64)>, 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::<Vec<_>>();
|
||||
if dash_split.len() != 2 {
|
||||
return Err(CgroupError::ParseError);
|
||||
@@ -165,7 +165,7 @@ fn parse_range(s: String) -> Result<Vec<(u64, u64)>, CgroupError> {
|
||||
}
|
||||
fin.push((first.unwrap(), second.unwrap()));
|
||||
} else {
|
||||
/* this is just a single number */
|
||||
// this is just a single number
|
||||
let num = sp.parse::<u64>();
|
||||
if num.is_err() {
|
||||
return Err(CgroupError::ParseError);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -109,10 +109,10 @@ impl V1 {
|
||||
}
|
||||
|
||||
fn find_v1_mount() -> Option<String> {
|
||||
/* 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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
16
src/pid.rs
16
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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user