NF

地方で働くプログラマ

ULKVMM 4日目

2章の概要、2章初めから2.1の直前まで。

    • -

2章 物理メモリについての解説

 Linuxは広い範囲のアーキテクチャで使用可能で、それらはアーキテクチャ固有のメモリの説明方法が必要となる。この章では、VMの挙動に影響を与えるメモリバンク、ページおよびフラグの話を続けるために使われる(?)構造について説明する。

 VMで一般に行われる最初の主要な構想は、非均一メモリ参照(NUMA)である。大規模な機械において、メモリはバンクに配置されるかもしれず、プロセッサからの"距離"に依存して参照のためのコストの違いを招く。例えば、メモリバンクは各CPUに割り当てられるか、あるいはメモリバンクはDMAにとても適切なデバイスカードに近づくかもしれない。

 各バンクはノードと呼ばれ、アーキテクチャUMAだとしても、構想はLinuxにおいてpglist_data構造体によって表現される。この構造体は常にそれのtypedefであるpg_data_tにより参照される。
システム内の全てのノードはpgdat_listと呼ばれるNULL終端リストで保存され、各ノードはpg_data_t->node_nextフィールドにより次の要素へリンクされる。PCデスクトップのようなUMAアーキテクチャのために、contig_page_dataと呼ばれるたった一つのpg_data_t構造体が使用される。ノードはもっと先の2.1章で議論されるだろう。

 各ノードはゾーンと呼ばれる幾つかのブロックに分割され、それらはメモリ内の距離を表す。ゾーンは関連のないアロケータを基礎としたゾーンと混同されるべきではない。1つのゾーンはzone_tにtypedefされるzone_struct構造体により表現され、1つ1つはZONE_DMA、ZONE_NORMALまたはZONE_HIGHMEMという型である。各ゾーンの型は使用法により適切な異なる型となる。
ZONE_DMAは物理メモリ範囲の低い(lower)メモリで、あるISAデバイスが要求する。ZONE_NORMALに属するメモリは、カーネルにより線形アドレス空間の高い(upper)領域に直接マップされ、もっと先の4.1章で議論される。ZONE_HIGHMEMはシステム内の残りの使用可能のメモリで、カーネルによって直接マップされない。
x86におけるゾーン、

  • ZONE_DMA ・・・メモリの最初の16MiB
  • ZONE_NORMAL ・・・16MiBから896MiB
  • ZONE_HIGHMEM ・・・896MiBから最後まで

 多くのカーネルオペレーションは、ZONE_NORMALを使用することのみが生じ得て、それは最も性能がクリティカルなゾーンであるということに気をつけることは重要である。ゾーンはこの先の2.2章で議論される。各物理尾エージフレームはpage構造体により表現され、全ての構造体はグローバルなmem_map配列で保存される。それらは大抵ZONE_NOMALの始めか低メモリ機械(?)の中でカーネルイメージをロードするために予約されている領域のすぐ後ろに記録される。pages構造体は2.4章で詳細に議論される。全ての構造体の基礎的な関連は図2.1に描写される。

【図 2.1 Relationship Between Nodes, Zones and Pages】

 カーネルによりメモリに直接的にアクセスし易いメモリ(ZONE_NORMAL)の量はサイズが制限されているので、Linuxはこの先の2.5で議論される「High Memory」という構想をサポートする。この章では、High Memory管理の紹介の前に、ノード、ゾーン及びページはどのように表現するかについて議論する。

    • -

(原文)

Chapter 2 Describing Physical Memory

 Linux is available for a wide range of architectures so there needs to be an
architecture-independent way of describing memory. This chapter describes the
structures used to keep account of memory banks, pages and the ags that aeect
VM behaviour.

 The rst principal concept prevalent in the VM is Non-Uniform Memory Access
(NUMA). With large scale machines, memory may be arranged into banks that
incur a dieerent cost to access depending on the distance from the processor. For
example, there might be a bank of memory assigned to each CPU or a bank of
memory very suitable for DMA near device cards.

 Each bank is called a node and the concept is represented under Linux by a
struct pglist_data even if the architecture is UMA. This struct is always refer-
enced to by it's typedef pg_data_t. Every node in the system is kept on a NULL
terminated list called pgdat_list and each node is linked to the next with the eld
pg_data_t!node_next. For UMA architectures like PC desktops, only one static
pg_data_t structure called contig_page_data is used. Nodes will be discussed
further in Section 2.1.

 Each node is divided up into a number of blocks called zones which represent
ranges within memory. Zones should not be confused with zone based allocators as
they are unrelated. A zone is described by a struct zone_struct, typedeeed to
zone_t and each one is of type ZONE_DMA, ZONE_NORMAL or ZONE_HIGHMEM. Each zone
type suitable a dieerent type of usage. ZONE_DMA is memory in the lower physical
memory ranges which certain ISA devices require. Memory within ZONE_NORMAL
is directly mapped by the kernel into the upper region of the linear address space
which is discussed further in Section 4.1. ZONE_HIGHMEM is the remaining available
memory in the system and is not directly mapped by the kernel.
 With the x86 the zones are:
  ZONE_DMA First 16MiB of memory
  ZONE_NORMAL 16MiB - 896MiB
  ZONE_HIGHMEM 896 MiB - End

 It is important to note that many kernel operations can only take place using
ZONE_NORMAL so it is the most performance critical zone. Zones are discussed further
in Section 2.2. Each physical page frame is represented by a struct page and all the structs are kept in a global mem_map array which is usually stored at the beginning
of ZONE_NORMAL or just after the area reserved for the loaded kernel image in low
memory machines. struct pages are discussed in detail in Section 2.4 and the
global mem_map array is discussed in detail in Section 3.7. The basic relationship
between all these structs is illustrated in Figure 2.1.

(Figure 2.1: Relationship Between Nodes, Zones and Pages)

 As the amount of memory directly accessible by the kernel (ZONE_NORMAL) is
limited in size, Linux supports the concept of High Memory which is discussed
further in Section 2.5. This chapter will discuss how nodes, zones and pages are
represented before introducing high memory management.

    • -

今回も幾つか訳せない箇所あり。1段落目の「the structures used to keep account of memory banks」とか。他にも、図2.1直前の「low memory machines」とか。lower/upperってメモリの位置の高低でいいんだろうか?lowerが0x00ってことなのかな・・・
訳が不安な箇所はありますが、時間を使っても判らないので取りあえずこのまま進めます。明日から帰省だけど、連休中にもう一歩進めたいなぁ