2011-02-13 72 views
2

通過閱讀Documentation/sysctl/vm.txt中的說明,我無法理解變量「lowmem_reserve_ratio」的含義。 我也試過谷歌它,但所有解釋發現是完全相同的目前在vm.txt。瞭解/ proc/sys/vm/lowmem_reserve_ratio

如果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%). 

回答

2

有同樣的問題,你,我用Google搜索(很多),並跌跌撞撞APON this page可能(也可能不)會比內核文檔更容易理解。

(這裏我就不引用,因爲這將是不可讀)

1

我發現,真正的文件太混亂中的措辭。看看mm/page_alloc.c的來源有助於澄清它,所以讓我試試看看更直接的解釋:

正如您在引用的頁面中所述,這些數字「是互惠數比」。有不同的看法:這些數字是除數。因此,在計算節點中給定區域的保留頁面時,可以將該節點中的頁面總和放在高於該節點的區域中,再除以提供的除數,這就是爲該區域保留的頁數。例如:我們假設一個1 GiB節點,其區域爲Normal區域,區域爲768 MiB,區域HighMem區域爲256 MiB(假設沒有區域DMA)。讓我們假設32的默認highmem保留「比率」(除數)。讓我們假設典型的4 KiB頁面大小。現在,我們可以計算出儲量區帶普通:

  1. 總和比帶普通(只是HIGHMEM) 「更高」 區域:256 MIB =(1024 KIB/1 MIB)*(1頁/ 4昆明植物研究所)= 65536頁
  2. 在區域中保留的區域對於該節點正常:65536頁/ 32 = 2048頁= 8 MiB。

當您添加更多區域和節點時,該概念保持不變。請記住,保留的大小是在頁面中---你永遠不會保留頁面的一小部分。