pub struct MemController { /* private fields */ }
Expand description
A controller that allows controlling the memory
subsystem of a Cgroup.
In essence, using the memory controller, the user can gather statistics about the memory usage of the tasks in the control group. Additonally, one can also set powerful limits on their memory usage.
Implementations§
Source§impl MemController
impl MemController
Sourcepub fn new(root: PathBuf, v2: bool) -> Self
pub fn new(root: PathBuf, v2: bool) -> Self
Contructs a new MemController
with root
serving as the root of the control group.
pub fn set_mem(&self, m: SetMemory) -> Result<()>
pub fn get_mem(&self) -> Result<SetMemory>
Sourcepub fn memory_stat(&self) -> Memory
pub fn memory_stat(&self) -> Memory
Gathers overall statistics (and the current state of) about the memory usage of the control group’s tasks.
See the individual fields for more explanation, and as always, remember to consult the kernel Documentation and/or sources.
Sourcepub fn kmem_stat(&self) -> Kmem
pub fn kmem_stat(&self) -> Kmem
Gathers information about the kernel memory usage of the control group’s tasks.
Sourcepub fn kmem_tcp_stat(&self) -> Tcp
pub fn kmem_tcp_stat(&self) -> Tcp
Gathers information about the control group’s kernel memory usage where said memory is TCP-related.
pub fn memswap_v2(&self) -> MemSwap
Sourcepub fn memswap(&self) -> MemSwap
pub fn memswap(&self) -> MemSwap
Gathers information about the memory usage of the control group including the swap usage (if any).
Sourcepub fn reset_fail_count(&self) -> Result<()>
pub fn reset_fail_count(&self) -> Result<()>
Reset the fail counter
Sourcepub fn reset_kmem_fail_count(&self) -> Result<()>
pub fn reset_kmem_fail_count(&self) -> Result<()>
Reset the kernel memory fail counter
Sourcepub fn reset_tcp_fail_count(&self) -> Result<()>
pub fn reset_tcp_fail_count(&self) -> Result<()>
Reset the TCP related fail counter
Sourcepub fn reset_memswap_fail_count(&self) -> Result<()>
pub fn reset_memswap_fail_count(&self) -> Result<()>
Reset the memory+swap fail counter
Sourcepub fn reset_max_usage(&self) -> Result<()>
pub fn reset_max_usage(&self) -> Result<()>
Reset the max memory usage recorded
Sourcepub fn set_limit(&self, limit: i64) -> Result<()>
pub fn set_limit(&self, limit: i64) -> Result<()>
Set the memory usage limit of the control group, in bytes.
Sourcepub fn set_kmem_limit(&self, limit: i64) -> Result<()>
pub fn set_kmem_limit(&self, limit: i64) -> Result<()>
Set the kernel memory limit of the control group, in bytes.
Sourcepub fn set_memswap_limit(&self, limit: i64) -> Result<()>
pub fn set_memswap_limit(&self, limit: i64) -> Result<()>
Set the memory+swap limit of the control group, in bytes.
Sourcepub fn set_tcp_limit(&self, limit: i64) -> Result<()>
pub fn set_tcp_limit(&self, limit: i64) -> Result<()>
Set how much kernel memory can be used for TCP-related buffers by the control group.
Sourcepub fn set_soft_limit(&self, limit: i64) -> Result<()>
pub fn set_soft_limit(&self, limit: i64) -> Result<()>
Set the soft limit of the control group, in bytes.
This limit is enforced when the system is nearing OOM conditions. Contrast this with the hard limit, which is always enforced.
Sourcepub fn set_swappiness(&self, swp: u64) -> Result<()>
pub fn set_swappiness(&self, swp: u64) -> Result<()>
Set how likely the kernel is to swap out parts of the address space used by the control group.
Note that a value of zero does not imply that the process will not be swapped out.
pub fn disable_oom_killer(&self) -> Result<()>
pub fn register_oom_event(&self, key: &str) -> Result<Receiver<String>>
Trait Implementations§
Source§impl Clone for MemController
impl Clone for MemController
Source§fn clone(&self) -> MemController
fn clone(&self) -> MemController
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for MemController
impl Debug for MemController
Source§impl<'a> From<&'a Subsystem> for &'a MemController
impl<'a> From<&'a Subsystem> for &'a MemController
Source§fn from(sub: &'a Subsystem) -> &'a MemController
fn from(sub: &'a Subsystem) -> &'a MemController
Auto Trait Implementations§
impl Freeze for MemController
impl RefUnwindSafe for MemController
impl Send for MemController
impl Sync for MemController
impl Unpin for MemController
impl UnwindSafe for MemController
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.