pub struct CgroupGroup<'a> { /* private fields */ }Expand description
RAII guard that removes cgroups on drop.
Prevents cgroup leaks when workload spawning or other operations fail between cgroup creation and cleanup.
Implementations§
Source§impl<'a> CgroupGroup<'a>
impl<'a> CgroupGroup<'a>
Sourcepub fn new(cgroups: &'a dyn CgroupOps) -> Self
pub fn new(cgroups: &'a dyn CgroupOps) -> Self
Create an empty group. Cgroups added via add_cgroup or
add_cgroup_no_cpuset are removed when the group is dropped.
Sourcepub fn add_cgroup(&mut self, name: &str, cpuset: &BTreeSet<usize>) -> Result<()>
pub fn add_cgroup(&mut self, name: &str, cpuset: &BTreeSet<usize>) -> Result<()>
Create a cgroup and set its cpuset. The cgroup is tracked for cleanup on drop.
Auto-enables Controller::Cpuset
on the parent’s cgroup.subtree_control before creating the
child so the child’s cpuset.cpus file is exposed and the
subsequent set_cpuset
write lands. Direct CgroupGroup users (the custom_* scenarios
in crate::scenario::nested / crate::scenario::stress)
don’t go through run_scenario’s
controller-resolution hook, so the controller enable has to
happen here. The setup call is idempotent on real cgroupfs (a
+cpuset write into cgroup.subtree_control that already
contains cpuset is a no-op at the kernel level per
cgroup_subtree_control_write in kernel/cgroup/cgroup.c).
Sourcepub fn add_cgroup_no_cpuset(&mut self, name: &str) -> Result<()>
pub fn add_cgroup_no_cpuset(&mut self, name: &str) -> Result<()>
Create a cgroup without a cpuset. The cgroup is tracked for cleanup on drop.
No controller enablement: callers explicitly opting out of a
cpuset signal that they don’t need any cgroup v2 controller
surface beyond the cgroup-core knobs (cgroup.procs,
cgroup.freeze) which are ungated. If a future caller needs
e.g. memory limits on a no-cpuset cgroup, add a
with_controllers overload rather than auto-enabling — the
“no-cpuset” name is load-bearing for the absent-controller
behavior pinned by tests in
crate::scenario::nested::custom_nested_cgroup_no_ctrl.
Trait Implementations§
Source§impl Debug for CgroupGroup<'_>
impl Debug for CgroupGroup<'_>
Auto Trait Implementations§
impl<'a> Freeze for CgroupGroup<'a>
impl<'a> !RefUnwindSafe for CgroupGroup<'a>
impl<'a> !Send for CgroupGroup<'a>
impl<'a> !Sync for CgroupGroup<'a>
impl<'a> Unpin for CgroupGroup<'a>
impl<'a> !UnwindSafe for CgroupGroup<'a>
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more