How do I Disable 1GB Pages on Linux*?
On x86 processors, pages are 4KiB in size by default. They are managed by software (primarily) in 4k units and the hardware memory management unit can map them at that granularity. However, the hardware may also support 2MB and 1GB pages. There are several user/kernel interfaces permitting application large-page use, and the kernel also has a number of internal uses. Generally, larger pages can offer performance benefits, however, they can also be harder to manage.
What if your hardware supports 1GB pages but you do not want to use them? Maybe you want to model some effects of moving to hardware without 1GB support, or you want the additional flexibility small pages provide. In that case, this article is for you.
Detecting 1GB Page Support and Use
How do you tell if 1GB pages are supported on your system? There are several methods to try.
$ cat /proc/cpuinfo | grep -c pdpe1gb 64
$ cat /proc/meminfo | grep 1G DirectMap1G: 2141192192 kB
$ ls -d /sys/kernel/mm/hugepages/hugepages-1048576kB/ /sys/kernel/mm/hugepages/hugepages-1048576kB/
- If you have a CPU which supports 1GB pages, you should see “pdpde1gb” in the “cpuinfo” file:
- You can examine if the kernel is using 1GB pages for its primary memory mapping, which is called the “direct map”. Even if a processor supports 1GB pages, the system memory layout might not be amenable to being mapped with 1GB pages. It might, for instance, have less than 1GB of total memory, or have holes in the address space for accessing devices.
- You can check whether 1GB pages are available for application use with the command:
Disabling 1GB Page Support
Each of the three uses above is driven from the processor’s enumeration of 1GB page support and does not have to be enabled as an individual feature. This enumeration can be overridden from the kernel command-line. To tell the kernel not to use 1GB pages, boot with the following on the kernel command-line:
Then check the above three support checks again. None should show up, or they may show up as 0 or report an error. The “58” value is known to work in the 5.4 kernel, but may not be stable over time. Older or newer kernels might use a different number.
Generating clearcpuid= Arguments
Since “58” is not guaranteed by the kernel to be stable over time, it might be necessary to use a different value for different kernel versions. The “58” can be recalculated by looking at the cpufeatures file. First, find the feature you want to disable:
#define X86_FEATURE_GBPAGES ( 1*32+26) /* "pdpe1gb" GB pages */
Then, do the “1*32+26” math to get 58. This method can be used to disable a wide variety of processor or kernel features in addition to 1GB pages.
Processor features such as large page sizes are critical for maximizing system performance. Understanding when larger pages are in use and how to control their use can illuminate the impact of these features on your system.
 Note, this command was run on a system with 64 logical CPUs. This number may be higher or lower depending on your system.