Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 3: Memory Management


Chapter 3: Memory Management............................................


allocations in the kernel area always land in physical RAM when this scheme is adopted. However,
there is one problem. The virtual address space portion of the kernel is necessarily smaller than the
maximum theoretical address space of the CPU. If there is more physical RAM than can be mapped
into the kernel address space, the kernel must resort to the highmem method to manage ‘‘super
fluous‘‘ memory. On IA-32 systems, up to 896 MiB of RAM can be managed directly; anything
above this figure (up to a maximum of 4 GiB)can only be addressed by means of highmem.

4 GiB is the maximum memory size that can be addressed on 32 -bit systems ( 232 = 4 GiB). If a trick
is used, modern IA-32 implementations — Pentium PRO and higher — can manage up to 64 GiB of
memory if PAE mode is enabled. PAE stands forpage address extensionand provides additional bits
for memory pointers. However, not all 64 GiB can be addressed at the same time, only sections of 4 GiB
each.

Because most memory management data structures can only be allocated in the range between 0 and
1 GiB, there is a practical limit to the maximum memory size and this is less than 64 GiB. The exact
value varies according to kernel configuration. For example, it is possible to allocate third-level page table
entries in highmem to reduce the load on the normal zone.

Because IA-32 systems with memory in excess of 4 GiB are a rarity and the 64 -bit architecture AMD64
that has for all practical purposes replaced IA-32 offers a much cleaner solution to this problem, I won’t
bother discussing the second highmem mode here.

Highmem mode is not required on 64-bit machines because the available address space is gigantic, even
if physical addressing is limited to a smaller number of bits, for example, 48 or 52. Given that exactly the
same was thought of the 4-GiB address space on 32-bit systems just a few years ago, one could argue
that it would merely seem to be a matter of time before the limits of 64-bit systems are reached, although
16 EiBshouldsuffice for some time. But you never know....

The use of highmem pages is problematic only for the kernel itself. The kernel
must first invoke thekmapandkunmapfunctions discussed below to map the
highmem pages into its virtual address space before it can use them — this is not
necessary with normal memory pages. However, for userspace processes, it makes
absolutely no difference if the pages are highmem or normal pages because they are
always accessed via page tables and never directly.

There are two types of machine that manage physical memory in different ways:


  1. UMA machines (uniform memory access) organize available memory in a contiguous fashion
    (possibly with small gaps). Each processor (in a symmetric multiprocessor system) is able to
    access each memory area equally quickly.

  2. NUMA machines (non-uniform memory access) are always multiprocessor machines. Local
    RAM is available to each CPU of the system to support particularly fast access. The proces-
    sors are linked via a bus to support access to the local RAM of other CPUs — this is naturally
    slower than accessing local RAM.
    Examples of such systems are Alpha-based WildFire servers and NUMA-Q machines
    from IBM.

Free download pdf