了解/ proc / sys / vm / lowmem_reserve_ratio

问题描述 投票:3回答:3

通过阅读Documentation / sysctl / vm.txt中的说明,我无法理解变量“ lowmem_reserve_ratio”的含义。我也尝试过搜索它,但是发现的所有解释都与vm.txt中的解释完全相似。

如果sb进行解释或提及某些链接,它将非常有帮助。原始说明如下:-

The lowmem_reserve_ratio is an array. You can see them by reading this file.
-
% cat /proc/sys/vm/lowmem_reserve_ratio
256     256     32
-
Note: # of this elements is one fewer than number of zones. Because the highest
      zone's value is not necessary for following calculation.

But, these values are not used directly. The kernel calculates # of protection
pages for each zones from them. These are shown as array of protection pages
in /proc/zoneinfo like followings. (This is an example of x86-64 box).
Each zone has an array of protection pages like this.

-
Node 0, zone      DMA
  pages free     1355
        min      3
        low      3
        high     4
        :
        :
    numa_other   0
        protection: (0, 2004, 2004, 2004)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  pagesets
    cpu: 0 pcp: 0
        :
-
These protections are added to score to judge whether this zone should be used
for page allocation or should be reclaimed.

In this example, if normal pages (index=2) are required to this DMA zone and
watermark[WMARK_HIGH] is used for watermark, the kernel judges this zone should
not be used because pages_free(1355) is smaller than watermark + protection[2]
(4 + 2004 = 2008). If this protection value is 0, this zone would be used for
normal page requirement. If requirement is DMA zone(index=0), protection[0]
(=0) is used.
zone[i]'s protection[j] is calculated by following expression.

(i < j):
  zone[i]->protection[j]
  = (total sums of present_pages from zone[i+1] to zone[j] on the node)
    / lowmem_reserve_ratio[i];
(i = j):
   (should not be protected. = 0;
(i > j):
   (not necessary, but looks 0)

The default values of lowmem_reserve_ratio[i] are
    256 (if zone[i] means DMA or DMA32 zone)
    32  (others).
As above expression, they are reciprocal number of ratio.
256 means 1/256. # of protection pages becomes about "0.39%" of total present
pages of higher zones on the node.

If you would like to protect more pages, smaller values are effective.
The minimum value is 1 (1/1 -> 100%).
linux memory-management virtual-machine procfs
3个回答
3
投票

与您有同样的问题,我用谷歌搜索(很多),偶然发现了this page,这可能(或可能没有)比内核文档更容易理解。

((这里我不引用,因为它不可读)


2
投票

我发现该文档中的措词也确实令人困惑。查看mm/page_alloc.c中的源代码有助于清除它,所以让我尝试更简单的解释:

如您引用的页面中所说,这些数字“是比率的倒数”。用不同的措词:这些数字是除数。因此,在计算节点中给定区域的保留页数时,您要将该节点中高于该区域的区域中的页数之和除以提供的除数,这就是您为该区域保留的页面数。

[示例:让我们假设一个1 GiB节点,在Normal区域中具有768 MiB,在HighMem区域中具有256 MiB(假定没有区域DMA)。假设默认的高内存保留“比率”(除数)为32。并假定典型的4 KiB页面大小。现在我们可以计算正常区域的保留区域:

  1. “高”区域的总和比正常区域(正好是HighMem):256 MiB =(1024 KiB / 1 MiB)*(1页/ 4 KiB)= 65536页]
  2. 在此节点的正常区域中保留的区域:65536页/ 32 = 2048页= 8 MiB。
  3. 当您添加更多区域和节点时,该概念保持不变。请记住,保留的大小以页为单位-您永远都不会保留页面的一小部分。


0
投票

我发现解释得非常清楚的内核源代码。

© www.soinside.com 2019 - 2024. All rights reserved.