You can find how much is allocated and how much is actually used by HugePages by run the following command.
$ grep -i huge /proc/meminfo AnonHugePages: 776192 kB HugePages_Total: 241 HugePages_Free: 113 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB
But, there’s a time you also want to know which applications are actually used HugePages. You can check it by go through the /proc/ directory. In each PID directory, you can find smaps which shows you the memory allocation details. You can use below script to check if it uses HugePages and how much uses it.
#!/bin/bash hugepage_size=`grep Hugepagesize: /proc/meminfo | awk '{print $2}'` echo "HugePageSize : " $hugepage_size " kB" for i in /proc/*/smaps; do if [[ $(grep '^KernelPageSize' $i | grep -v '4 kB$') ]]; then echo "" egrep -e "^KernelPageSize: [ ]*$hugepage_size kB$" $i -B 11 | egrep -e '^Size:' | awk 'BEGIN {sum = 0} { sum += $2 } END {print "Total HugePage used : " sum " kB"}' fi; done
Output would be like below.
# ./checkhugepage.sh HugePageSize : 2048 kB Total HugePage used : 262144 kB
Leave a Reply