numactl
Introduction
The numactl tool can be used to view the NUMA node configuration and status of the current server. You can use this tool to bind processes to a specified CPU core so that the specified CPU core can run the corresponding processes.
Command examples:
Command |
Description |
|---|---|
numactl -H |
Views the NUMA configuration of the current server. |
numactl -C 0-7 ./test |
Binds the application program test to cores 0 to 7. |
numastat |
Views the running status of the current NUMA. |
Installation Method
Take CentOS as an example. Run the following command to install the tool:
1 | # yum -y install numactl numastat
|
How to Use
- Run the numactl command to view the NUMA configuration of the current server.
The numactl command output shows that the server is divided into four NUMA nodes. Each node contains 16 CPU cores, and the memory size of each node is about 64 GB. In addition, the command output provides the distance between different nodes. The longer the distance, the higher the latency of cross-NUMA memory access. Reduce cross-NUMA memory access when the application is running.

- Run the numactl command to bind the process to a specified CPU core.
The numactl -C 0-15 top command binds the top process to CPU cores 0 to 15.

- Run the numastat command to check the memory access hit ratio of the current NUMA node.

You can run the numastat command to check the status of each NUMA node.
- numa_hit indicates the number of times that the CPU core accesses the local memory.
- numa_miss indicates the number of times that the CPU core accesses the memory of other nodes. Cross-node memory access has high latency and deteriorates performance. Therefore, the smaller the value of numa_miss, the better. If the value is too large, consider core binding.