merlin2011
merlin2011

Reputation: 75555

Is there a canonical programmatic way to query for the set of cores belonging to a NUMA node?

One can obtain the set of cores belonging to each NUMA node using the following shell command.

$ lscpu | grep NUMA
NUMA node(s):          2
NUMA node0 CPU(s):     0-7,16-23
NUMA node1 CPU(s):     8-15,24-31

While it is not difficult to parse this output to determine the set of cores belonging to each NUMA node, it is fragile to depend on the formatted output of a shell command to collect such information.

Is there a canonical API in Linux to determine which set of cores belong to which NUMA node?

For example, a system call or a set of files under /proc or /sys.

Upvotes: 2

Views: 1118

Answers (1)

merlin2011
merlin2011

Reputation: 75555

Based on the source code of lscpu and the kernel documentation, it looks like the relevant information is available at the following two special paths for each NUMA node.

/sys/devices/system/node/nodeX/cpulist
/sys/devices/system/node/nodeX/cpumap

Moreover, one can get the names of the NUMA nodes from the following path.

/sys/devices/system/node/possible

Upvotes: 2

Related Questions