https://access.redhat.com/solutions/2592
What are Huge Pages and the advantages of using them?
SOLUTION 已验证 - 已更新 2014年六月25日18:18 -
环境
- Red Hat Enterprise Linux 6
- Red Hat Enterprise Linux 5
- Red Hat Enterprise Linux 4
问题
- What are Huge Pages and what are the advantages of using them?
- How do I enable huge pages?
- Does it require reboot to update the huge page value on the system?
- How to check hugepage parameter ?
决议
-
Hugepages is a feature that allows the Linux kernel to utilize the multiple page size capabilities of modern hardware architectures. Linux creates multiple pages of virtual memory, mapped from both physical RAM and swap. A page is the basic unit of virtual memory, with the default page size being 4096 Bytes in the x86 architecture.
-
Linux uses a mechanism in the CPU architecture called "Translation Lookaside Buffers" (TLB) to manage the mapping of virtual memory pages to actual physical memory addresses. The TLB is a limited hardware resource, so utilizing a huge amount of physical memory with the default page size consumes the TLB and adds processing overhead - many pages of size 4096 Bytes equates to many TLB resources consumed. By utilizing Huge Pages, we are able to create pages of much larger sizes, each page consuming a single resource in the TLB. A side effect of creating Huge Pages is that the physical memory that is mapped to a Huge Page is no longer subject to normal memory allocations or managed by the kernel virtual memory manager, so Huge Pages are essentially 'protected' and are available only to applications that request them. Huge Pages are 'pinned' to physical RAM and cannot be swapped/paged out.
-
A typical purpose for allocating Huge Pages is for an application that has characteristic high memory use, and you wish to ensure that the pages it uses are never swapped out when the system is under memory pressure. Another purpose is to manage memory usage on a 32bit system - Creating Huge Pages and configuring applications to use them will reduce the kernel's memory management overhead since it will be managing fewer pages. The kernel virtual memory manager utilizes low memory - fewer pages to manage means it will consume less low memory.
-
In the Linux 2.6 series of kernels, hugepages is enabled using the
CONFIG_HUGETLB_PAGEfeature when the kernel is built. All kernels supplied by Red Hat for the Red Hat Enterprise Linux 4 release and later releases have the feature enabled. -
Systems with large amount of memory can be configured to utilize the memory more efficiently by setting aside a portion dedicated for hugepages. The actual size of the page is dependent on the system architecture. A typical x86 system will have a Huge Page Size of 2048 kBytes. The huge page size may be found by looking at
/proc/meminfo:# cat /proc/meminfo |grep Hugepagesize Hugepagesize: 2048 kB -
In RHEL 6 or later, the
hugepagesizecan be displayed using the following command (this value is in bytes):# hugeadm --page-sizes-all 2097152Starting with RHEL 6, Transparent Huge Pages are also available.
Note: Enabling hugepages requires the kernel to find contiguous, aligned unallocated regions of memory. For most systems, this means that a reboot will be required to allocate the hugepages.
For more information on hugepages, visit the following links:
- RHEL 4 and RHEL 5 Tuning Guide
- RHEL 6 Documentation
- Knowledge Solution: Enabling hugepages for use with Oracle Database on RHEL 5 and RHEL 6.

本文深入探讨了HugePages的工作原理及优势,解释了其如何通过减少Translation Lookaside Buffers资源消耗来提高内存效率,特别是在高内存使用场景下,如32位系统中减少内核内存管理开销。
5993

被折叠的 条评论
为什么被折叠?



