You are on page 1of 1

SUBSCRIPTIONS DOWNLOADS CONTAINERS SUPPORT CASES   Radu Litescu 


Products & Services Tools Security Community


7
Products & Services  Knowledgebase  [RHEL] How do I check for hugepages usage and what is using it?


[RHEL] How do I check for hugepages usage and what is using it?
$ SOLUTION VERIFIED - Updated February 25 2019 at 11:32 AM - English

Environment
Red Hat Enterprise Linux 5
Red Hat Enterprise Linux 6
Red Hat Enterprise Linux 7
Red Hat Enterprise Linux 8

Issue
How do I check for what is using my system hugepages?
How to caculate the size of hugepage used by a specified process?

Resolution
Kernel perspective
Get notified when this content is updated FOLLOW b
1. First, check for the current hugepages usage:

Raw

[root@server ~]# grep HugePages_ /proc/meminfo


HugePages_Total: 16299
HugePages_Free: 7764
HugePages_Rsvd: 5330
HugePages_Surp: 0

2. Now, let's deduct the free pages, so we can find the used pages and sum to it the reserved pages. So the allocated pages is going to be
Total - Free + Rsvd

Raw

16299 - 7764 + 5330 = 13865

3. Multiply the alloocated pages by 2048 (2048 is the number of kbytes of a single page)

Raw

13865 x 2048 = 28,395,520 kbytes

4. If you want to put the kbytes in byte count, multiply it by 1024 (1 kbyte = 1024 bytes):

Raw

28395520 x 1024 = 29,077,012,480 bytes

Where is the memory

You can easily quantify the shared hugepages memory. To do so:

1. List the shared memory in use:

Raw

[root@rfreire sys]# ipcs -m


------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 163840 oracle 640 14680064 50
0x00000000 196609 oracle 640 2499805184 50
0x27126a4c 229378 oracle 640 2097152 50
0x00000000 5636099 oracle 640 33554432 58
0x00000000 5668868 oracle 640 4160749568 58
[...]

2. Sum the 5th column (quick shell: ipcs -m|awk '{ print $5}'|awk '{a+=$0}END{print a}' ) and match against /proc/meminfo hugepages
information (see procedure above). If the values matches, then you have a hugepages-only shared memory. If you get a larger value, you have
4kb regular pages shared memory in use as well. Just deduct this sum from /proc/meminfo hugepages value in bytes and then you'll find how
much you have of regular 4kb pages.

Check if you are using a hugepages filesystem. Grep for huge in /proc/mounts :

Raw

[root@server ~]# grep -i huge /proc/mounts


none /hugepages hugetlbfs rw,relatime 0 0

Unfortunately, at this time there are no means to quantify private hugetlbfs pages, which are used for qemu-kvm , for example.

How to caculate the size of hugepage used by a specified process

The following command can be used to caculate the size of hugepage used by a specified process, assumption that HugePage size is 2048
kB, the output unit is MiB:

Raw

grep -B 11 'KernelPageSize: 2048 kB' /proc/[PID]/smaps | grep "^Size:" | awk 'BEGIN{sum=0}{sum+=$2}END{print sum/1024}'

Note: avoid double counting of the same address in /proc/[PID]/smaps.

Product(s) Red Hat Enterprise Linux Component kernel Category Troubleshoot Tags hugepages kernel memory rhel_6 rhel_7 rhel_8

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while
supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and
unedited form.

Was this helpful? YES NO

People who viewed this solution also viewed

Memory size by free and ipcs contain also How do I calculate used Hugepages? How do I tell which application is using
HugePages which HugePages?

Solution - Jan 22, 2016 Solution - Feb 24, 2019 Solution - Feb 25, 2019

1 Comments

RL
NEWBIE

2 Points

Laurie Howland 23 October 2013 4:16 PM

LH I poked around in /proc/vm/$pid/numa_stat and found some info that appears to be hugepage usage.

I came up with this:


NEWBIE

7 Points function pshugepage () {


HUGEPAGECOUNT=0
for num in grep 'anon_hugepage.*dirty=' /proc/$@/numa_maps | awk '{print $6}' | sed 's/dirty=//' ; do
HUGEPAGECOUNT=$((HUGEPAGECOUNT+num))
done
echo process $@ using $HUGEPAGECOUNT huge pages
}

I can't swear it is correct, but the numbers it gives are plausible.

≤ Reply

QUICK LINKS HELP SITE INFO RELATED SITES ABOUT

Downloads Contact Us Trust Red Hat redhat.com Red Hat Subscription


Value
Subscriptions Customer Portal FAQ Browser Support Policy openshift.com
About Red Hat
Support Cases Log-in Assistance Accessibility developers.redhat.com
Red Hat Jobs
Customer Service Awards and Recognition connect.redhat.com

Product Documentation Colophon

All systems operational

Copyright © 2021 Red Hat, Privacy Statement Customer Portal Terms of Use All Policies and Guidelines  
Inc. Cookie Preferences

You might also like