ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

为什么RHEL系统使用交换空间而不是释放缓存和缓冲内存?

2021-06-28 13:35:35  阅读:247  来源: 互联网

标签:kernel 缓存 vm pages swappiness RHEL memory swap 内存


环境

  • Red Hat Enterprise Linux (RHEL) All versions

问题

  • Why does my system utilize swap space instead of freeing up cache and buffer memory?
  • What is the impact of scaling up and down the value of "swappiness"?
  • Why am I getting out of memory while swap is unused?
  • Why swap is not being used or under used?

决议

  • The kernel uses heuristics to guess which pages of memory are likely to be needed in the near future and tries to keep those pages in memory, regardless of whether they belong to processes or kernel caches. It is normal for the kernel to swap out process memory, even when there is plenty of cache memory that could easily be freed.

  • The swappiness parameter controls the tendency of the kernel to move processes out of physical memory and onto the swap disk.

  • The kernel heuristics can be tuned by changing the vm.swappiness parameter of sysctl. The default value, which is 60, is reasonable for most workloads, but some systems may benefit from lower or higher values. Increasing this value will make the system more inclined to swap inactive memory pages to disk, rather than dropping pages from the page cache, leaving more memory free for cached I/O. This may be preferred for heavy I/O workloads. Decreasing this value will make the system less inclined to swap, and more inclined to drop pages from the page cache.

  • Tuning vm.swappiness may hurt performance, or may have a different impact between light and heavy workloads. Changes to this parameter should be made in small increments, and should be tested under the same conditions that the system normally operates.

  • For example, to set the vm.swappiness parameter to 50:

Raw
    # echo '50'> /proc/sys/vm/swappiness
  • To make this setting persistent across reboots, add this line to the /etc/sysctl.conf file:
Raw
    vm.swappiness = 50

Note: while vm.swappiness accepts 0-100 values, it should not be set to 0, as this can cause an unexpected behaviour on the system. 0 is a special value which works differently depending on the RHEL version in use:

  • Prior to RHEL 6.4: vm.swappiness = 0 disables swapping for the most part, except to avoid an out-of-memory situation.
  • RHEL 6.4 and later: vm.swappines = 0 disables swapping in most cases, If we set swappiness==0, the kernel does not swap out completely (for global reclaim until the amount of free pages and filebacked pages in a zone has been reduced to something very very small (nr_free + nr_filebacked < high watermark)).

诊断步骤

Value of swappiness can be checked as follow:

Raw
$ cat /proc/sys/vm/swappiness

标签:kernel,缓存,vm,pages,swappiness,RHEL,memory,swap,内存
来源: https://www.cnblogs.com/augusite/p/14944060.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有