Configuring Huge Pages in Oracle Linux
Introduces Oracle Linux huge page features and points to HugeTLB and Transparent HugePages configuration guidance.
In Oracle Linux, physical memory is managed in fixed-size blocks called pages. In the x86_64 architecture, the default size of each page is 4 KB.
The kernel stores virtual to physical address mappings for the pages in a data structure known as the page table. However, page table lookups are resource-intensive, so the most recently used addresses are cached in the CPU's Translation Lookaside Buffer (TLB) for faster retrieval. When the CPU needs to fulfill a request for an address-mapping, the CPU first searches the TLB cache. A TLB hit describes the CPU finding the address in the TLB cache. A TLB miss describes the CPU unable to find the requested address-mapping in the cache, in which case the system would perform a resource intensive lookup on the page table to retrieve the address information.
The default page size of 4 KB is suitable for most applications. However, for applications that work with large amounts of memory, the number of 4 KB pages required can be large and can lead to a high number of TLB misses and a performance overhead. Oracle Linux provides huge page features so that applications requiring more memory can have their requirements fulfilled with fewer pages.
HugeTLB Pages
HugeTLB pages are also called static huge pages.
With the HugeTLB pages feature, you can reserve pools of huge pages, each of a specified quantity, for each huge page size. The available huge page size options on x86_64 platforms are 2 MB and 1 GB.
Best Practices:
- Make requests to the kernel for static huge pages as close to boot time as possible, when the occurrence of memory fragmentation is at a minimum.
- Huge pages can reduce the amount of memory available to the system. Therefore, when requesting a reserved huge page pool, ensure the pool isn't oversized and that the system's access to memory isn't impacted.
Transparent HugePages
The Transparent HugePages (THP) feature is enabled by default in Oracle Linux. The kernel automatically assigns huge pages to processes, and on x86_64 platforms THP assigns only 2 MB pages.
THP can run in the following modes:
system-wide(default): The kernel assigns huge pages to processes that use large contiguous virtual memory areas whenever it's possible to do so.per-process:The kernel only assigns huge pages to application processes that explicitly request huge pages through themadvise()system call.
For more information about configuring THP, see Configuring Transparent HugePages