Created
October 17, 2023 12:30
-
-
Save jflopezfernandez/503f00d507203607748f0a4314e179ef to your computer and use it in GitHub Desktop.
View hugepages information about the current system.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Get the number of hugepages currently configured on the system. | |
# | |
# Sample output: | |
# Hugepages: | |
# Total: 0 (0) | |
# Free: 0 (0) | |
# Surplus: 0 (0) | |
# | |
# Get the number of NUMA nodes on the current host. | |
NUMA_NODES=$(ls --directory /sys/devices/system/node/node* | wc --lines) | |
# Get hugepages information for each NUMA node on the system. | |
for NUMA_NODE in $(seq 0 $(($NUMA_NODES - 1))); do | |
TOTAL_HUGEPAGES=$(cat /sys/devices/system/node/node$NUMA_NODE/hugepages/hugepages-1048576kB/nr_hugepages) | |
FREE_HUGEPAGES=$(cat /sys/devices/system/node/node$NUMA_NODE/hugepages/hugepages-1048576kB/free_hugepages) | |
SURPLUS_HUGEPAGES=$(cat /sys/devices/system/node/node$NUMA_NODE/hugepages/hugepages-1048576kB/surplus_hugepages) | |
echo "Hugepages:" | |
echo -e "\tTotal: $TOTAL_HUGEPAGES ($NUMA_NODE)" | |
echo -e "\tFree: $FREE_HUGEPAGES ($NUMA_NODE)" | |
echo -e "\tSurplus: $SURPLUS_HUGEPAGES ($NUMA_NODE)" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment