Question: How to Calculate the percentage of memory reserved by Huge Pages?

1. Inspect the memory parameters:

# cat /proc/meminfo
MemTotal: 98721456 kB
MemFree: 1277612 kB
MemAvailable: 12186676 kB
Buffers: 20496 kB
Cached: 11013124 kB
SwapCached: 4820 kB
Active: 2303780 kB
Inactive: 9716992 kB
Active(anon): 716672 kB
Inactive(anon): 582092 kB
Active(file): 1587108 kB
Inactive(file): 9134900 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 33554428 kB
SwapFree: 32965424 kB
Dirty: 16856 kB
Writeback: 0 kB
AnonPages: 1004112 kB
Mapped: 308188 kB
Shmem: 290944 kB
Slab: 694100 kB
SReclaimable: 602280 kB
SUnreclaim: 91820 kB
KernelStack: 13792 kB
PageTables: 75736 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 40956756 kB
Committed_AS: 3011596 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 256480 kB
VmallocChunk: 34359477292 kB
HardwareCorrupted: 0 kB
AnonHugePages: 0 kB
CmaTotal: 0 kB
CmaFree: 0 kB
HugePages_Total: 40975
HugePages_Free: 35867
HugePages_Rsvd: 13
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 163840 kB
DirectMap2M: 14516224 kB
DirectMap1G: 87031808 kB

2. Calculate the percentage of memory used by HugePages:

memory% = (HugePages_Total * Hugepagesize) / MemTotal * 100.0

3. Use the values appropriate for your system, taken from the /proc/meminfo report. For example, from the example above:

memory% = (HugePages_Total * Hugepagesize) / MemTotal * 100.0 
memory% = (40975 * 2048) / 98721456 * 100.0
memory% = 83916800 / 98721456 * 100.0
memory% = 85.04

The HugePages configuration reserves about 85% of the physical memory on the server.

Note that all values in /proc/meminfo use the same units, so no conversion is necessary.