Linux Kernel Architecture

(Jacob Rumans) #1

Chapter3:MemoryManagement


The figure includes only those function calls associated with memory management. All others are
unimportant in this context and are therefore omitted. Recall thatsetup_archis invoked from within
start_kernel, as already noted in Section 3.4.1.


machine_specific_memory_setupis first invoked to create a list with the memory regions occupied by
the system and the free memory regions. Because the way in which this information is obtained differs
slightly between the ‘‘subarchitectures‘‘ of the IA-32 family,^11 the kernel provides a machine-specific
function that is defined ininclude/asm-x86/mach-type/setup.c.typecan then stand fordefault,
voyager,orvisws; I discuss only the default situation.


A map provided by the BIOS and showing the individual memory regions is used in this case.


These are not the same regions as in the NUMA concept but are areas occupied by
system ROM, for example, or by ACPI functions.

When the system is booted, the regions found are displayed by the kernel functionprint_memory_map.


wolfgang@meitner>dmesg
...
BIOS-provided physical RAM map:
BIOS-e820: 0000000000000000 - 000000000009e800 (usable)
BIOS-e820: 000000000009e800 - 00000000000a0000 (reserved)
BIOS-e820: 00000000000c0000 - 00000000000cc000 (reserved)
BIOS-e820: 00000000000d8000 - 0000000000100000 (reserved)
BIOS-e820: 0000000000100000 - 0000000017cf0000 (usable)
BIOS-e820: 0000000017cf0000 - 0000000017cff000 (ACPI data)
BIOS-e820: 0000000017cff000 - 0000000017d00000 (ACPI NVS)
BIOS-e820: 0000000017d00000 - 0000000017e80000 (usable)
BIOS-e820: 0000000017e80000 - 0000000018000000 (reserved)
BIOS-e820: 00000000ff800000 - 00000000ffc00000 (reserved)
BIOS-e820: 00000000fff00000 - 0000000100000000 (reserved)
...

If this information is not provided by the BIOS (this may be the case on some older machines), the kernel
itself generates a table to mark memory in the ranges 0–640 KiB and 1 MiBendas usable.


The kernel then analyzes the command line withparse_cmdline_early, concentrating on arguments like
mem=XXX[KkmM],highmem=XXX[kKmM],ormemmap=XXX[KkmM]""@XXX[KkmM]arguments. The administrator
can overwrite the size of available memory or manually define memory areas if the kernel calculates
an incorrect value or is provided with a wrong value by the BIOS. This option is only of relevance on
older computers.highmem=permits overwriting of the highmem size value detected. It can be used on
machines with a very large RAM configuration to limit available RAM size — as it sometimes yields
performance gains.


(^11) There are not only ‘‘normal‘‘ IA-32 computers but also custom products of Silicon Graphics and NCR that, although they consist
mainly of standard components, take a different approach to some things — including memory detection. Because these machines
are either very old (Voyager from NCR) or not in widespread use (Visual Workstation from SGI), I won’t bother with their oddities.

Free download pdf