Sungju's Slow Life

Personal journal

How to check which applications are using hugepages

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.


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"}'

Output would be like below.

# ./ 
HugePageSize :  2048 kB

Total HugePage used : 262144 kB

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: