透明大页介绍

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.

查看是否启用透明大页

1:命令cat /sys/kernel/mm/redhat_transparent_hugepage/enabled 该命令适用于Red Hat Enterprise Linux系统

[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:命令cat /sys/kernel/mm/transparent_hugepage/enabled 该命令适用于其它Linux系统

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

使用命令查看时,如果输出结果为[always]表示透明大页启用了。[never]表示透明大页禁用、[madvise]表示(只在MADV_HUGEPAGE标志的VMA中使用THP

3:如何HugePages_Total返回0,也意味着标准大页禁用了(注意传统/标准大页和透明大页的区别)

透明大页(THP)管理和标准/传统大页(HP)管理都是操作系统为了减少页表转换消耗的资源而发布的新特性,虽然ORACLE建议利用大页机制来提高数据库的性能,但是ORACLE却同时建议关闭透明大页管理。这二者的区别在于大页的分配机制,标准大页管理是预分配的方式,而透明大页管理则是动态分配的方式。

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

4:cat /proc/sys/vm/nr_hugepages返回0也意味着传统大页禁用了(传统大页和透明大页)。

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

禁用、启用透明大页功能

方法1:设置/etc/grub.conf文件,在系统启动是禁用。

[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

方法2:设置/etc/rc.local文件

[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 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 ~]# 

小知识点:

1:从RedHat 6, OEL 6, SLES 11 and UEK2 kernels 开始,系统缺省会启用 Transparent HugePages :用来提高内存管理的性能透明大页(Transparent HugePages )和之前版本中的大页功能上类似。主要的区别是:Transparent HugePages 可以实时配置,不需要重启才能生效配置;

2:Transparent Huge Pages在32位的RHEL 6中是不支持的。

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

3: ORACLE官方不建议我们使用RedHat 6, OEL 6, SLES 11 and UEK2 kernels 时的开启透明大页(Transparent HugePages ), 因为透明大页(Transparent HugePages ) 存在一些问题:

1.在RAC环境下 透明大页(Transparent HugePages )会导致异常节点重启,和性能问题;

2.在单机环境中,透明大页(Transparent HugePages ) 也会导致一些异常的性能问题;

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:安装Vertica Analytic Database时也必须关闭透明大页功能。

参考资料:

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

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

转载于:https://www.cnblogs.com/kerrycode/p/4670931.html

Linux 关于Transparent Hugepages的介绍相关推荐

  1. 怎么在RHEL7上禁用transparent hugepages (THP)

    原文标题: How to disable transparent hugepages (THP) on Red Hat Enterprise Linux 7 原文网址: https://access. ...

  2. linux 内存管理 Transparent HugePages 透明大页 简介

    1. 介绍 从RedHat6, RedHat7, OL6, OL7 SLES11 and UEK2 kernels开始,透明大页默认是被开启的以便去改善操作系统的内存管理.透明大页与之前版本的传统意义 ...

  3. oracle anonhugepage,案例:Oracle linux redhat检查Transparent HugePages状态并关闭

    天萃荷净 ALERT: Disable Transparent HugePages on SLES11, RHEL6, OEL6 and UEK2 Kernels 随着去ioe的潮流越来越汹涌,随着内 ...

  4. 如何将Transparent HugePages关闭

    [root@localhost ~]# grep Huge /proc/meminfo AnonHugePages:      2048 kB HugePages_Total:       0 Hug ...

  5. Centos7禁用THP(Transparent HugePages)

    开启THP精髓是提高内存分配效率,减少CPU SYS开销. 1.首先检查THP的启用状态: [root@localhost ~]# cat /sys/kernel/mm/transparent_hug ...

  6. Linux网络常用工具分类介绍

    Linux网络命令较多,单纯的介绍网络命令的用法也没什么意思.本文将常见的网络命令进行分类,并做出思维导图,对每个分类的命令选择性的介绍其作用.常见选项和用法举例.BTW,不建议记住所有命令,了解一下 ...

  7. Window VNC远程控制LINUX:VNC详细配置介绍

    Window VNC远程控制LINUX:VNC详细配置介绍 //---------------------------------------vnc linux下的详细配置 1.VNC的启动/停止/重 ...

  8. linux cpu uuid 查看,Linux下查看UUID方法介绍

    Linux下查看UUID方法介绍. 1. sudo blkid /dev/sda1: UUID="9ADAAB4DDAAB250B" TYPE="ntfs" / ...

  9. linux下变量名长度,Linux中shell的变量介绍

    Linux中shell的变量介绍 发布时间:2020-06-24 16:20:39 来源:亿速云 阅读:112 作者:元一 这期内容当中的小编将会给大家带来有关Linux中shell的变量介绍,以专业 ...

最新文章

  1. Hibernate 参数设置一览表
  2. mysql 远程登录权限
  3. python3 json解析_Python3 JSON编码解码方法详解
  4. luogu_1495【题解】中国剩余定理
  5. python能做什么excel-python处理excel总结
  6. NYOJ--289--苹果
  7. MSSQL表别名使用注意事项
  8. [C#源码] 微信跳一跳POST修改分数漏洞
  9. SQLServer 删除表中重复数据(除ID不同的)
  10. 阿里云盘 Mac客户端(附福利兑换码)
  11. 关于让div元素垂直居中的几种方法
  12. LM4871(3W音频功放芯片)中文资料
  13. 计算机管理磁盘分区,一分钟搞定电脑磁盘分区,再也不求人!
  14. Android应用程序启动时出现白色背景问题
  15. 基于搜狐新闻数据【完整版】训练中文word2vec模型
  16. (翻译)箭头和省略号的使用方式
  17. 广州楼市:这种楼盘谨慎购买,未来难转手,投资请回避!
  18. yolov算法详解_YOLOv4算法解读(思维导图)和论文翻译
  19. webm转换成mp4格式怎么转
  20. JDBC连接数据库读超时

热门文章

  1. 菜鸟javascript整理2
  2. qr分解求线性方程组_矩阵分解
  3. c语言编写python库_c语言包装python程序
  4. 相同MAC地址,相同IP的两天电脑为什么可以同时上网互不影响(转自Nothel的blog)
  5. docker helowin 迁移_禅道在docker上部署与迁移
  6. 文本分类训练集 测试集_【AI1000问】训练为什么要分测试集和验证集?
  7. 用心摘种一树技能,植树节送3本书
  8. 让我当你的圣诞老人吧,派发3本技术好书
  9. Fiddler 抓包(二)—Android
  10. 百度论文引用网络节点分类比赛