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%).
4

3 に答える 3

4

あなたと同じ問題を抱えているので、私は(たくさん)グーグルで調べて、カーネルドキュメントよりも理解しやすいかもしれない(またはそうでないかもしれない)このページに出くわしました。

(読みにくいのでここでは引用しません)

于 2011-05-12T15:02:18.913 に答える
2

その文書の文言も非常に紛らわしいことがわかりました。のソースを見ると、mm/page_alloc.cそれが明確になるので、より簡単な説明を試してみましょう。

あなたが引用したページで述べられているように、これらの数値は「比率の逆数」です。別の言い方をすると、これらの数値は約数です。したがって、ノード内の特定のゾーンの予約ページを計算するときは、そのノード内のそのノードよりも上位のゾーンにあるページの合計を取得し、指定された除数で割ります。これが、そのゾーンに予約しているページ数になります。

例: ゾーン Normal に 768 MiB、ゾーン HighMem に 256 MiB を持つ 1 GiB ノードを想定します (ゾーン DMA はないと仮定します)。デフォルトの highmem 予約の "比率" (除数) が 32 であると仮定しましょう。また、典型的な 4 KiB ページ サイズを仮定しましょう。これで、ゾーン Normal の予約領域を計算できます。

  1. 通常のゾーンよりも「高い」ゾーンの合計 (HighMem のみ): 256 MiB = (1024 KiB / 1 MiB) * (1 ページ / 4 KiB) = 65536 ページ
  2. ゾーンで予約されている領域 このノードの標準: 65536 ページ / 32 = 2048 ページ = 8 MiB。

ゾーンとノードを追加しても、概念は変わりません。予約サイズはページ単位であることを覚えておいてください。ページの一部を予約することはありません。

于 2014-10-24T07:52:04.353 に答える