Skip to main content

NodeResolution

Enum NodeResolution 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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.

§

TopologyUnavailable

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_node enforces a single-u64 nodemask limit (see the InvalidNode error 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().

§

Unavailable

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 GetNumaProcessorNodeEx fails or returns the MAXUSHORT sentinel.
  • Under the numa_shim_mock cfg when the scripted node is NO_NODE.

current_node returns None for this case.

Trait Implementations§

Source§

impl Clone for NodeResolution

Source§

fn clone(&self) -> NodeResolution

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for NodeResolution

Source§

impl Debug for NodeResolution

Source§

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

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

impl Eq for NodeResolution

Source§

impl Hash for NodeResolution

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for NodeResolution

Source§

fn eq(&self, other: &NodeResolution) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for NodeResolution

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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.