pub enum MemPolicy {
Default,
Bind(BTreeSet<usize>),
Preferred(usize),
Interleave(BTreeSet<usize>),
Local,
PreferredMany(BTreeSet<usize>),
WeightedInterleave(BTreeSet<usize>),
}Expand description
NUMA memory placement policy for worker processes.
Applied via set_mempolicy(2) after fork, before the work loop.
Maps to Linux MPOL_* constants. When Default, no syscall is
made (inherits the parent’s policy).
Optional MpolFlags modify behavior (e.g. STATIC_NODES to
keep the nodemask absolute across cpuset changes).
Variants§
Default
Inherit the parent process’s memory policy (no syscall).
Bind(BTreeSet<usize>)
Allocate only from the specified NUMA nodes (MPOL_BIND).
Preferred(usize)
Prefer allocations from the specified node, falling back to
others when the preferred node is full (MPOL_PREFERRED).
Interleave(BTreeSet<usize>)
Interleave allocations round-robin across the specified nodes
(MPOL_INTERLEAVE).
Local
Prefer the nearest node to the CPU where the allocation occurs
(MPOL_LOCAL). No nodemask.
PreferredMany(BTreeSet<usize>)
Prefer allocations from any of the specified nodes, falling back
to others when all preferred nodes are full
(MPOL_PREFERRED_MANY, kernel 5.15+).
WeightedInterleave(BTreeSet<usize>)
Weighted interleave across the specified nodes. Page distribution
is proportional to per-node weights set via
/sys/kernel/mm/mempolicy/weighted_interleave/nodeN
(MPOL_WEIGHTED_INTERLEAVE, kernel 6.9+).
Implementations§
Source§impl MemPolicy
impl MemPolicy
Sourcepub fn bind(nodes: impl IntoIterator<Item = usize>) -> Self
pub fn bind(nodes: impl IntoIterator<Item = usize>) -> Self
Construct a Bind policy from any iterator of NUMA node IDs.
Accepts arrays, ranges, Vec, BTreeSet, or any IntoIterator<Item = usize>.
Sourcepub const fn preferred(node: usize) -> Self
pub const fn preferred(node: usize) -> Self
Construct a Preferred policy for a single NUMA node.
Sourcepub fn interleave(nodes: impl IntoIterator<Item = usize>) -> Self
pub fn interleave(nodes: impl IntoIterator<Item = usize>) -> Self
Construct an Interleave policy from any iterator of NUMA node IDs.
Accepts arrays, ranges, Vec, BTreeSet, or any IntoIterator<Item = usize>.
Sourcepub fn preferred_many(nodes: impl IntoIterator<Item = usize>) -> Self
pub fn preferred_many(nodes: impl IntoIterator<Item = usize>) -> Self
Construct a PreferredMany policy from any iterator of NUMA node IDs.
Sourcepub fn weighted_interleave(nodes: impl IntoIterator<Item = usize>) -> Self
pub fn weighted_interleave(nodes: impl IntoIterator<Item = usize>) -> Self
Construct a WeightedInterleave policy from any iterator of NUMA node IDs.
Sourcepub fn node_set(&self) -> BTreeSet<usize>
pub fn node_set(&self) -> BTreeSet<usize>
NUMA node IDs referenced by this policy.
Returns the node set for Bind, Interleave, PreferredMany,
and WeightedInterleave, a single-element set for Preferred,
and an empty set for Default/Local.
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Validate that this policy’s node set is non-empty where required.
Returns Err with a description when a node-set-bearing policy
has an empty set. Each diagnostic names the offending variant,
the constraint (“at least one NUMA node”), and the actionable
fix — both the matching constructor and the recommended
fallbacks for “I don’t want node-restricted placement” — so the
operator sees the next mouse-click inline rather than having to
cargo doc --open to discover the constructor menu. Mirrors the
workers_pct rejection trailer at WorkSpec::resolve_workers_pct.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for MemPolicy
impl<'de> Deserialize<'de> for MemPolicy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for MemPolicy
impl StructuralPartialEq for MemPolicy
Auto Trait Implementations§
impl Freeze for MemPolicy
impl RefUnwindSafe for MemPolicy
impl Send for MemPolicy
impl Sync for MemPolicy
impl Unpin for MemPolicy
impl UnwindSafe for MemPolicy
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