How do I get 4 MB huge pages on Linux

295 Views Asked by At

According to:

$ ls -l /sys/kernel/mm/hugepages

drwxr-xr-x 2 root root 0 Dec  6 10:38 hugepages-1048576kB
drwxr-xr-x 2 root root 0 Dec  6 10:38 hugepages-2048kB

There is a choice of 2 MB and 1 GB sizes of huge pages on my system which is running a 5.4.17 kernel

However according to:

$ cpuid | grep -i tlb |sort| uniq

      0x03: data TLB: 4K pages, 4-way, 64 entries
      0x63: data TLB: 2M/4M pages, 4-way, 32 entries
      0x76: instruction TLB: 2M/4M pages, fully, 8 entries
      0xb5: instruction TLB: 4K, 8-way, 64 entries
      0xc3: L2 TLB: 4K/2M pages, 6-way, 1536 entries
   cache and TLB information (2):
            data TLB: 1G pages, 4-way, 4 entries
   L1 TLB/cache information: 2M/4M pages & L1 TLB (0x80000005/eax):
   L1 TLB/cache information: 4K pages & L1 TLB (0x80000005/ebx):
   L2 TLB/cache information: 2M/4M pages & L2 TLB (0x80000006/eax):
   L2 TLB/cache information: 4K pages & L2 TLB (0x80000006/ebx):

the TLBs on my Skylake also support 4 MB pages. The same information can be found at

https://en.wikichip.org/wiki/intel/microarchitectures/skylake_(server)

So the question is: can I really have 4 MB pages, and if so what do I need to do to set up my system to have that option?

1

There are 1 best solutions below

0
Dan Bonachea On

The best answer is probably to install and/or use libhugetlbfs

If it's already installed, you can check status of huge pages in the OS with a command like:

$ hugeadm --pool-list
      Size  Minimum  Current  Maximum  Default
   2097152        0        1   257388        *
   4194304        0        0   128694         
   8388608        0        0    64347         
  16777216        0        0    32173         
  33554432        0        0    16086         
  67108864        0        0     8043         
 134217728        0        0     4021         
 268435456        0        0     2010         
 536870912        0        0     1005         
1073741824        0        0      502         
2147483648        0        0      251         

The same hugeadm command can also be run as sudo with various options to configure the available huge memory pools. See the hugeadm man page for details.