How to check if NUMA settings are applied in Linux

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, you will learn how to check if Non-Uniform Memory Access (NUMA) settings are applied in Linux. Understanding NUMA is crucial for optimizing performance on multi-processor systems.

Through a series of hands-on steps, you will utilize essential Linux commands like numactl and lscpu, and explore the /proc/numa filesystem to verify and inspect the NUMA configuration on your system. This lab will provide you with the practical skills to identify NUMA nodes, associated CPUs, and memory, ensuring you can effectively assess your system's NUMA setup.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("Linux")) -.-> linux/BasicSystemCommandsGroup(["Basic System Commands"]) linux(("Linux")) -.-> linux/BasicFileOperationsGroup(["Basic File Operations"]) linux(("Linux")) -.-> linux/FileandDirectoryManagementGroup(["File and Directory Management"]) linux(("Linux")) -.-> linux/PackagesandSoftwaresGroup(["Packages and Softwares"]) linux/BasicSystemCommandsGroup -.-> linux/help("Command Assistance") linux/BasicSystemCommandsGroup -.-> linux/man("Manual Access") linux/BasicFileOperationsGroup -.-> linux/ls("Content Listing") linux/BasicFileOperationsGroup -.-> linux/cat("File Concatenating") linux/FileandDirectoryManagementGroup -.-> linux/which("Command Locating") linux/PackagesandSoftwaresGroup -.-> linux/apt("Package Handling") subgraph Lab Skills linux/help -.-> lab-558800{{"How to check if NUMA settings are applied in Linux"}} linux/man -.-> lab-558800{{"How to check if NUMA settings are applied in Linux"}} linux/ls -.-> lab-558800{{"How to check if NUMA settings are applied in Linux"}} linux/cat -.-> lab-558800{{"How to check if NUMA settings are applied in Linux"}} linux/which -.-> lab-558800{{"How to check if NUMA settings are applied in Linux"}} linux/apt -.-> lab-558800{{"How to check if NUMA settings are applied in Linux"}} end

Check NUMA status with numactl --hardware

In this step, we will begin exploring Non-Uniform Memory Access (NUMA) architecture on your system. NUMA is a computer memory design used in multiprocessing, where the memory access time depends on the memory location relative to the processor. Understanding NUMA can be important for optimizing performance in certain applications.

We will use the numactl command to check the NUMA status. The numactl command is used to control NUMA policy for processes or run a program with a specific NUMA policy.

First, let's check if the numactl command is available on your system. Type the following command in your terminal and press Enter:

which numactl

If numactl is installed, you will see the path to the executable, something like:

/usr/bin/numactl

If it's not installed, you might see an empty output or an error message. If it's not installed, you can install it using apt. Since you have sudo privileges without a password, you can run:

sudo apt update
sudo apt install numactl -y

Now that numactl is available, let's use the --hardware option to display information about the NUMA nodes on your system. Type the following command and press Enter:

numactl --hardware

You should see output similar to this, which lists the available NUMA nodes and their associated CPUs and memory:

available: 1 nodes (0)
node 0 cpus: 0 1
node 0 size: 1999 MB
node 0 free: 1800 MB

This output indicates that your system has 1 NUMA node (node 0). It also shows which CPUs belong to this node and the total and free memory available to it. The exact output may vary depending on the virtual machine configuration.

Understanding this output is the first step in working with NUMA systems. In the next steps, we will explore more ways to inspect NUMA configuration.

Click Continue to proceed to the next step.

Verify NUMA nodes in /proc/numa

In this step, we will explore the /proc filesystem to find information about NUMA nodes. The /proc filesystem is a virtual filesystem that provides information about processes and other system information. It's a great place to find details about your Linux system's configuration and status.

Specifically, we will look at the /proc/numa directory. This directory contains files that provide details about the NUMA configuration.

First, let's list the contents of the /proc/numa directory using the ls command. Type the following command in your terminal and press Enter:

ls /proc/numa

You should see output similar to this:

distance  nodes

This indicates that there are two main files or directories related to NUMA in /proc: distance and nodes.

Now, let's examine the contents of the /proc/numa/nodes file. This file should list the available NUMA nodes. We can use the cat command to display the content of this file. Type the following command and press Enter:

cat /proc/numa/nodes

You should see output similar to this:

0

This output confirms that your system has at least one NUMA node, which is node 0. If your system had more NUMA nodes, you would see a list of node numbers here (e.g., 0 1).

Next, let's look at the /proc/numa/distance file. This file shows the distance between NUMA nodes, which represents the cost of accessing memory on a different node. For a single-node system, the distance to itself is typically 10. Type the following command and press Enter:

cat /proc/numa/distance

You should see output similar to this:

0: 10

This output shows the distance matrix. In this case, 0: 10 means the distance from node 0 to node 0 is 10. On systems with multiple NUMA nodes, you would see a matrix showing the distance between all pairs of nodes.

Exploring the /proc filesystem is a common way to gather system information in Linux. You've now seen how to use it to verify the NUMA nodes detected on your system.

Click Continue to move on to the next step.

Inspect NUMA details with lscpu

In this final step, we will use the lscpu command to get detailed information about the CPU architecture, including NUMA configuration. The lscpu command displays information about the CPU(s) in the system and can be very useful for understanding your system's hardware.

Type the following command in your terminal and press Enter:

lscpu

You will see a comprehensive output about your CPU. Look for lines that mention "NUMA". The output will vary depending on the system, but you should see something similar to this:

Architecture:        x86_64
...
NUMA node(s):        1
NUMA node0 CPU(s):   0,1

Let's break down the relevant parts of the output:

  • NUMA node(s): 1: This line tells you the total number of NUMA nodes detected on the system. In this case, it's 1, which aligns with what we saw using numactl and checking /proc/numa.
  • NUMA node0 CPU(s): 0,1: This line shows which CPU cores belong to NUMA node 0. Here, it indicates that CPUs 0 and 1 are part of node 0.

The lscpu command provides a lot of other useful information about your CPU, such as the number of cores, threads, cache sizes, and supported features. Feel free to scroll through the output and see what other details you can find.

You have now successfully used three different methods (numactl --hardware, /proc/numa, and lscpu) to inspect the NUMA configuration of your system. Understanding these tools is essential for diagnosing performance issues and optimizing applications on multi-processor systems.

Click Continue to complete this lab and review your progress.

Summary

In this lab, we learned how to check if NUMA settings are applied in Linux. We began by using the numactl --hardware command to display information about the available NUMA nodes, including associated CPUs and memory. This provided a foundational understanding of the NUMA architecture on the system.

We then explored alternative methods for verifying NUMA configuration. This included inspecting the /proc/numa file system, which provides detailed information about NUMA nodes and their memory statistics. Finally, we utilized the lscpu command to obtain a comprehensive overview of the CPU architecture, including NUMA-related details, further confirming the system's NUMA setup.