#[non_exhaustive]pub enum NodeResolution {
Resolved(u32),
TopologyUnavailable,
Unavailable,
}Expand description
Outcome of a NUMA-node determination attempt for the calling thread.
This enum provides finer-grained status information than the simpler
Option<u32> returned by current_node, exposing WHY a node could
not be determined rather than just that it could not.
As of task #1308, current_node itself fails closed — it returns None
for every non-Resolved outcome — so the distinction this enum exposes is
diagnostic (“WHY detection failed”) not a way to recover a node-0 answer.
current_node remains the recommended function for most callers; use
current_node_resolution() for diagnostic logging / warnings that NUMA
hints may not be effective.
See task #1266, audit finding F4 for background, and task #1308 for the fail-closed origin.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Resolved(u32)
The calling thread’s CPU was genuinely resolved to this NUMA node via the platform topology.
This variant is returned on Linux when the CPU index from
sched_getcpu(2) was found in one of the cached sysfs
/sys/devices/system/node/nodeN/cpumap files, on Windows when
GetCurrentProcessorNumberEx + GetNumaProcessorNodeEx succeed,
or under the numa_shim_mock cfg when the scripted node is not
NO_NODE. Note that Resolved(0) can legitimately indicate a
genuinely single-node system.
Deliberately carries no field-level #[non_exhaustive] (see task
#778/F13 for the precedent this follows): this is a single scalar
field (the resolved node ID) with no plausible second field to grow
into, so marking it would force callers into weaker matches!
patterns for no real growth path this shape needs to reserve. The
enum-level #[non_exhaustive] above still protects against future
variants.
Linux only: the CPU index was obtained, but no cached sysfs cpumap contains it.
This occurs when:
- The real topology was unreadable (e.g., sysfs permissions or I/O errors during the first-call cache population).
- The CPU lives on a NUMA node >= 64 — the implementation scans
only nodes 0..63 because
reserve_preferred_on_nodeenforces a single-u64nodemask limit (see theInvalidNodeerror in that function’s documentation). - The kernel has no NUMA sysfs at all (single-node system where
the
/sys/devices/system/node/directory is absent).
current_node returns None for this variant as well (task #1308
— it previously collapsed it into Some(0)). This variant exists
to distinguish “the platform HAS a NUMA API and detection ran, but
this specific CPU could not be resolved” from NodeResolution::Unavailable
(“the platform has no NUMA API / the OS call itself failed”) — a real,
useful distinction for diagnostic/logging callers even though both map
to None in current_node().
The platform provides no NUMA API, or the OS API failed.
This is returned on:
- macOS (no public NUMA API).
- miri (no real OS topology).
- Unsupported platforms (e.g., FreeBSD, other Unix).
- Linux when
sched_getcpu(2)fails (returns -1). - Windows when
GetNumaProcessorNodeExfails or returns theMAXUSHORTsentinel. - Under the
numa_shim_mockcfg when the scripted node isNO_NODE.
current_node returns None for this case.
Trait Implementations§
Source§impl Clone for NodeResolution
impl Clone for NodeResolution
Source§fn clone(&self) -> NodeResolution
fn clone(&self) -> NodeResolution
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more