Struct cgroups_rs::memory::MemController
source · [−]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
sourceimpl 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
sourceimpl Clone for MemController
impl Clone for MemController
sourcefn clone(&self) -> MemController
fn clone(&self) -> MemController
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresourceimpl Debug for MemController
impl Debug for MemController
sourceimpl<'a> From<&'a Subsystem> for &'a MemController
impl<'a> From<&'a Subsystem> for &'a MemController
sourcefn from(sub: &'a Subsystem) -> &'a MemController
fn from(sub: &'a Subsystem) -> &'a MemController
Auto Trait Implementations
impl RefUnwindSafe for MemController
impl Send for MemController
impl Sync for MemController
impl Unpin for MemController
impl UnwindSafe for MemController
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<T> Controller for Twhere
T: ControllerInternal,
impl<T> Controller for Twhere
T: ControllerInternal,
sourcefn 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.
sourcefn 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.
sourcefn tasks(&self) -> Vec<CgroupPid, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
fn tasks(&self) -> Vec<CgroupPid, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
Get the list of tasks that this controller has.