Introduction to Transparent Hugepages in Linux, transparent

Source: Internet
Author: User

Introduction to Transparent Hugepages in Linux, transparent

Introduction to transparent big pages

Some official information about Transparent Huge Pages:

Transparent Huge Pages (THP)Are enabled by default in RHEL 6 for all applications. the kernel attempts to allocate hugepages whenever possible and any Linux process will receive 2 MB pages if the mmap region is 2 MB naturally aligned. the main kernel address space itself is mapped with hugepages, which causes TLB pressure from kernel code. for general information on Hugepages, see: What are Huge Pages and what are the advantages Using them?

The kernel will always attempt to satisfy a memory allocation using hugepages. if no hugepages are available (due to non availability of physically continuous memory for example) the kernel will fall back to the regular 4KB pages. THP are also swappable (unlike hugetlbfs ). this is achieved by breaking the huge page to smaller 4KB pages, which are then swapped out normally.

But to use hugepages extends tively, the kernel must find physically continuous areas of memory big enough to satisfy the request, and also properly aligned. for this, a khugepaged kernel thread has been added. this thread will occasionally attempt to substitute smaller pages being used currently with a hugepage allocation, thus maximizing THP usage.

In userland, no modifications to the applications are necessary (hence transparent ). but there are ways to optimize its use. for applications that want to use hugepages, use of posix_memalign () can also help ensure that large allocations are aligned to huge page (2 MB) boundaries.

Also, THP is only enabled for anonymous memory regions. there are plans to add support for tmpfs and page cache. THP tunables are found in the/sys tree under/sys/kernel/mm/redhat_transparent_hugepage.

Check whether transparent large pages are enabled

1: Command cat/sys/kernel/mm/redhat_transparent_hugepage/enabled this command is applicable to Red Hat Enterprise Linux systems

[root@getlnx06 ~]# more /etc/issue
 
Red Hat Enterprise Linux Server release 6.6 (Santiago)
 
Kernel \r on an \m
 
[root@getlnx06 ~]# cat /sys/kernel/mm/redhat_transparent_hugepage/enabled
 
[always] madvise never

2: Command cat/sys/kernel/mm/transparent_hugepage/enabled. This command is applicable to other Linux systems.

[root@getlnx06 ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
 
always madvise [never]
 
[root@getlnx06 ~]# 

If the output result is [always], the large transparent page is enabled. [Never] indicates that large transparent pages are disabled, and [madvise] indicates

3: How to return 0 for HugePages_Total also means that the large transparent page is disabled

[root@getlnx06 ~]# grep -i HugePages_Total /proc/meminfo 
 
HugePages_Total: 0

4: If cat/proc/sys/vm/nr_hugepages returns 0, the large transparent page is disabled.

[root@getlnx06 ~]# cat /proc/sys/vm/nr_hugepages 
 
0

Disable and enable the transparent large page feature

Method 1: Set the/etc/grub. conf file, which is disabled at system startup.

[root@getlnx06 ~]# vi /etc/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/VolGroup--LogVol0-LogVol01
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux 6 (2.6.32-504.el6.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-504.el6.x86_64 ro root=/dev/mapper/VolGroup--LogVol0-LogVol01 rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=VolGroup-LogVol0/LogVol01 rd_LVM_LV=VolGroup-LogVol0/LogVol00  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
        initrd /initramfs-2.6.32-504.el6.x86_64.img
transparent_hugepage=never

Method 2: Set the/etc/rc. local file

[root@getlnx06 ~]# vi /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
 
touch /var/lock/subsys/local
 
if test -f /sys/kernel/mm/redhat_transparent_hugepage/enabled; then
   echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled
fi

After the preceding configuration is used, the operating system must be restarted to take effect. You can also run the following command without restarting the operating system.

You must reboot your system for the setting to take effect, or run the following two echo lines to proceed with the install without rebooting:

[root@getlnx06 ~]# echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled
[root@getlnx06 ~]# cat /sys/kernel/mm/redhat_transparent_hugepage/enabled
always madvise [never]
[root@getlnx06 ~]# 

TIPS:

1: From RedHat 6, OEL 6, SLES 11 and UEK2 kernels, Transparent HugePages is enabled by default: Transparent HugePages is used to improve memory management performance) it is similar to the big page feature in earlier versions. The main difference is that Transparent HugePages can be configured in real time, and the configuration does not need to be restarted;

2: Transparent Huge Pages are not supported in 32-bit RHEL 6.

Transparent Huge Pages are not available on the 32-bit version of RHEL 6.

3: ORACLE officially does not recommend that you enable Transparent HugePages when using RedHat 6, OEL 6, SLES 11 and UEK2 kernels) there are some problems:

1. In the RAC environment, Transparent HugePages may cause abnormal node restart and performance problems;

2. In a single-host environment, Transparent HugePages may also cause some abnormal performance problems;

Transparent HugePages memory is enabled by default with Red Hat Enterprise Linux 6, SUSE Linux Enterprise Server 11, and Oracle Linux 6 with earlier releases of Oracle Linux Unbreakable Enterprise Kernel 2 (UEK2) kernels. transparent HugePages memory is disabled in later releases of Oracle Linux UEK2 kernels. transparent HugePages can cause memory allocation delays during runtime. to avoid performance issues, Oracle recommends that you disable Transparent HugePages on all Oracle Database servers. oracle recommends that you instead use standard HugePages for enhanced performance. transparent HugePages memory differs from standard HugePages memory because the kernel khugepaged thread allocates memory dynamically during runtime. standard HugePages memory is pre-allocated at startup, and does not change during runtime.

Starting with RedHat 6, OEL 6, SLES 11 and UEK2 kernels, Transparent HugePages are implemented and enabled (default) in an attempt to improve the memory management. transparent HugePages are similar to the HugePages that have been available in previous Linux releases. the main difference is that the Transparent HugePages are set up dynamically at run time by the khugepaged thread in kernel while the regular HugePages had to be preallocated at the boot up time. because Transparent HugePages are known to cause unexpected node reboots and performance problems with RAC, Oracle stronugly advises to disable the use of Transparent HugePages. in addition, Transparent Hugepages may cause problems even in a single-instance database environment with unexpected performance problems or delays. as such, Oracle recommends disabling Transparent HugePages on all Database servers running Oracle.

4: When Vertica Analytic Database is installed, the transparent large page function must also be disabled.

References:

Https://access.redhat.com/solutions/46111

Http://www.soso.io/article/65143.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.