pub struct CpuController { /* private fields */ }
Expand description
A controller that allows controlling the cpu
subsystem of a Cgroup.
In essence, it allows gathering information about how much the tasks inside the control group are using the CPU and creating rules that limit their usage. Note that this crate does not yet support managing realtime tasks.
Implementations§
Source§impl CpuController
impl CpuController
Sourcepub fn new(root: PathBuf, v2: bool) -> Self
pub fn new(root: PathBuf, v2: bool) -> Self
Contructs a new CpuController
with root
serving as the root of the control group.
Sourcepub fn cpu(&self) -> Cpu
pub fn cpu(&self) -> Cpu
Returns CPU time statistics based on the processes in the control group.
Configures the CPU bandwidth (in relative relation to other control groups and this control group’s parent).
For example, setting control group A
’s shares
to 100
, and control group B
’s
shares
to 200
ensures that control group B
receives twice as much as CPU bandwidth.
(Assuming both A
and B
are of the same parent)
Retrieve the CPU bandwidth that this control group (relative to other control groups and this control group’s parent) can use.
Sourcepub fn set_cfs_period(&self, us: u64) -> Result<()>
pub fn set_cfs_period(&self, us: u64) -> Result<()>
Specify a period (when using the CFS scheduler) of time in microseconds for how often this control group’s access to the CPU should be reallocated.
Sourcepub fn cfs_period(&self) -> Result<u64>
pub fn cfs_period(&self) -> Result<u64>
Retrieve the period of time of how often this cgroup’s access to the CPU should be reallocated in microseconds.
Sourcepub fn set_cfs_quota(&self, us: i64) -> Result<()>
pub fn set_cfs_quota(&self, us: i64) -> Result<()>
Specify a quota (when using the CFS scheduler) of time in microseconds for which all tasks
in this control group can run during one period (see: set_cfs_period()
).
Sourcepub fn cfs_quota(&self) -> Result<i64>
pub fn cfs_quota(&self) -> Result<i64>
Retrieve the quota of time for which all tasks in this cgroup can run during one period, in microseconds.
pub fn set_cfs_quota_and_period( &self, quota: Option<i64>, period: Option<u64>, ) -> Result<()>
pub fn set_rt_runtime(&self, us: i64) -> Result<()>
pub fn set_rt_period_us(&self, us: u64) -> Result<()>
Trait Implementations§
Source§impl Clone for CpuController
impl Clone for CpuController
Source§fn clone(&self) -> CpuController
fn clone(&self) -> CpuController
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for CpuController
impl Debug for CpuController
Source§impl<'a> From<&'a Subsystem> for &'a CpuController
impl<'a> From<&'a Subsystem> for &'a CpuController
Source§fn from(sub: &'a Subsystem) -> &'a CpuController
fn from(sub: &'a Subsystem) -> &'a CpuController
Auto Trait Implementations§
impl Freeze for CpuController
impl RefUnwindSafe for CpuController
impl Send for CpuController
impl Sync for CpuController
impl Unpin for CpuController
impl UnwindSafe for CpuController
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Controller for Twhere
T: ControllerInternal,
impl<T> Controller for Twhere
T: ControllerInternal,
Source§fn apply(&self, res: &Resources) -> Result<(), Error>
fn apply(&self, res: &Resources) -> Result<(), Error>
Apply a set of resources to the Controller, invoking its internal functions to pass the kernel the information.
Source§fn add_task_by_tgid(&self, pid: &CgroupPid) -> Result<(), Error>
fn add_task_by_tgid(&self, pid: &CgroupPid) -> Result<(), Error>
Attach a task to this controller by thread group id.