Close transparent large page

Some official presentation materials 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 2MB pages if the mmap region is 2MB naturally aligned. The main kernel address space itself is mapped with hugepages, reducing TLB pressure from kernel code. For general information on Hugepages, see: What are Huge Pages and what are the advantages of 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 effectively, 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 (2MB) 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 to enable transparent large pages

1: command cat / sys / kernel / mm / redhat_transparent_hugepage / enabled the command applies to Red Hat Enterprise Linux system

[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 applies to other Linux systems

[root @ getlnx06 ~] # CAT / SYS / Kernel / mm / transparent_hugepage / Enabled
 
Always madvise [Never]
 
[root @ getlnx06 ~] #
when using the command to see if the output is [always] means transparent large pages are enabled. [never] means transparent large page disable, [madvise] representation

 

3: How HugePages_Total returns 0, also means transparent large page disabled

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

4: cat / proc / sys / vm / nr_hugepages return 0 means transparent large page is disabled.

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

Disable, Enable transparent large pages feature

 

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

[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

 



You must restart the operating system using the above configuration 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 ~]#
 

Small knowledge:

1: From the RedHat 6, OEL 6, SLES 11 and UEK2 kernels start, the system will be enabled by default Transparent HugePages: Similar to improve performance on memory management transparent huge pages (Transparent HugePages) and previous versions of large pages feature. The main difference is: Transparent HugePages real-time configuration, no need to restart to take effect configuration;

 

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

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

 

3: ORACLE official is not to suggest that we use RedHat 6, OEL 6, SLES 11 and UEK2 kernels turn transparent when large pages (Transparent HugePages), because the transparent large page (Transparent HugePages) there are some problems:

        1. In a RAC environment transparent large page (Transparent HugePages) can lead to abnormal node restart, and performance issues;

        2. In a stand-alone environment, transparent large page (Transparent HugePages) will lead to some unusual performance issues;

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 strongly 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: you must close the transparent large page feature when you install Vertica Analytic Database.

 

References:

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

http://www.soso.io/article/65143.html
---------------------
author: no longer crazy to stupid
Source: CSDN
Original: https: //blog.csdn.net/bzfys/article/details/77816571
Disclaimer: This article is a blogger original article, reproduced, please attach Bowen link!

Guess you like

Origin www.cnblogs.com/chendian0/p/11199077.html