#[non_exhaustive]pub struct MemoryLimits {
pub max: Option<u64>,
pub high: Option<u64>,
pub low: Option<u64>,
pub swap_max: Option<u64>,
}Expand description
Memory controller limits (memory.max / memory.high /
memory.low / memory.swap.max). Each field is None by
default (inherit from parent / no limit).
Set via CgroupDef::memory_max, CgroupDef::memory_high,
CgroupDef::memory_low, CgroupDef::memory_unlimited,
CgroupDef::memory_swap_max, or
CgroupDef::memory_swap_unlimited. Construct directly only
when copying a MemoryLimits across CgroupDefs — the
builder methods are the preferred entry point because they
keep test code in chain position and route the per-knob value
through the framework’s validation seam at apply_setup.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.max: Option<u64>memory.max hard ceiling in bytes. Crossing this triggers
the cgroup OOM killer per Documentation/admin-guide/ cgroup-v2.rst’s “Memory Interface Files”. None writes
"max" (no hard limit).
high: Option<u64>memory.high soft throttle threshold in bytes. Crossing
this triggers reclaim throttling but NOT OOM-kill. None
writes "max".
low: Option<u64>memory.low soft protection threshold in bytes. The kernel
preferentially reclaims FROM other cgroups before reclaiming
this cgroup’s memory below low. None writes "0" (no
protection).
swap_max: Option<u64>memory.swap.max ceiling on the cgroup’s swap usage in bytes.
None writes "max" (no swap cap, the kernel default). The
kernel parses the wire value via page_counter_memparse —
either the literal "max" or a decimal byte count
(swap_max_write in mm/memcontrol.c).
§CONFIG_SWAP=n kernel detection
memory.swap.max only exists when the kernel was built with
CONFIG_SWAP=y; on swap-disabled builds the file is absent
and the wire-time write returns ENOENT. The framework only
emits the write when swap_max.is_some() — the explicit
opt-in matches the per-knob semantics of the pids block, so
tests that never call CgroupDef::memory_swap_max /
CgroupDef::memory_swap_unlimited succeed verbatim on a
swap-disabled kernel.
swap_max = Some(N) on a CONFIG_SWAP=n kernel surfaces
as a hard scenario failure: apply_setup propagates the
ENOENT from set_memory_swap_max’s write_with_timeout up
the error chain with the memory.swap.max filename in the
context. Test authors who target the swap controller must
either (a) gate the swap_max call on a host probe, or (b)
require the test kernel be built with CONFIG_SWAP=y and
document the requirement on the test.
§ktstr’s kernel config and swap
ktstr.kconfig (the project-level kernel-config fragment that
cargo ktstr merges into the test kernel’s defconfig) does
NOT pin CONFIG_SWAP=y — swap is not a test-framework
requirement, and many test scenarios run faster without it.
Tests that call memory_swap_max therefore must either
extend the per-test kconfig fragment (passed alongside
ktstr.kconfig at kernel-build time) or detect at
scenario-setup time by reading /proc/swaps (a missing
file or empty body indicates no swap subsystem) or
/proc/config.gz (search for CONFIG_SWAP=y). The framework
does NOT auto-detect because host probing is policy that
belongs to the test author, not the workload runner.
Trait Implementations§
Source§impl Clone for MemoryLimits
impl Clone for MemoryLimits
Source§fn clone(&self) -> MemoryLimits
fn clone(&self) -> MemoryLimits
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MemoryLimits
impl Debug for MemoryLimits
Source§impl Default for MemoryLimits
impl Default for MemoryLimits
Source§fn default() -> MemoryLimits
fn default() -> MemoryLimits
Source§impl PartialEq for MemoryLimits
impl PartialEq for MemoryLimits
impl Eq for MemoryLimits
impl StructuralPartialEq for MemoryLimits
Auto Trait Implementations§
impl Freeze for MemoryLimits
impl RefUnwindSafe for MemoryLimits
impl Send for MemoryLimits
impl Sync for MemoryLimits
impl Unpin for MemoryLimits
impl UnwindSafe for MemoryLimits
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§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