CgroupGroup

Struct CgroupGroup 

Source
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>

Source

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.

Source

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).

Source

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.

Source

pub fn names(&self) -> &[String]

Names of all tracked cgroups.

Trait Implementations§

Source§

impl Debug for CgroupGroup<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for CgroupGroup<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more