Skip to main content

pin_thread_to_numa_node

Function pin_thread_to_numa_node 

Source
pub fn pin_thread_to_numa_node(node: NumaNode) -> Result<(), String>
Expand description

Pin the current thread to a specific NUMA node’s CPUs.

This sets the CPU affinity for the calling thread to only run on CPUs belonging to the specified NUMA node. This is critical for ensuring that memory allocations follow the first-touch policy on the correct node.

§Arguments

  • node - The NUMA node to pin the thread to

§Errors

Returns an error if:

  • NUMA topology cannot be read
  • No CPUs are found for the specified node
  • The sched_setaffinity syscall fails