From 6b60e5311d47112abf7cff638072dfa68985e7dc Mon Sep 17 00:00:00 2001 From: nileshnegi Date: Sun, 10 May 2026 18:50:37 -0500 Subject: [PATCH] Fix set_mempolicy EINVAL for memory-less NUMA nodes during topology init CollectTopology() probes each NUMA node by allocating a small buffer, which calls numa_set_preferred(i) for all numa_num_configured_nodes(). If some nodes have no memory backing, set_mempolicy(MPOL_PREFERRED) returns EINVAL for them. Guard the call with numa_get_mems_allowed() so only nodes with real memory get a preferred policy set. Co-authored-by: Claude --- src/header/TransferBench.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/header/TransferBench.hpp b/src/header/TransferBench.hpp index 9f4589c..34511ba 100644 --- a/src/header/TransferBench.hpp +++ b/src/header/TransferBench.hpp @@ -1548,7 +1548,10 @@ namespace { if (IsCpuMemType(memType)) { // Set NUMA policy prior to call to hipHostMalloc - numa_set_preferred(deviceIdx); + // Skip memory-less NUMA nodes to avoid set_mempolicy EINVAL + if (deviceIdx < 0 || numa_bitmask_isbitset(numa_get_mems_allowed(), deviceIdx)) { + numa_set_preferred(deviceIdx); + } // Allocate host-pinned memory (should respect NUMA mem policy) int flags = 0;