Linux Kernel Architecture

(Jacob Rumans) #1

Chapter3:MemoryManagement


Table 3-1: Correlation between Main Memory Size and Minimum Memory Available
for Critical Allocations.

Main memory Reserve

16 MiB 512 KiB

32 MiB 724 KiB

64 MiB 1024 KiB

128 MiB 1448 KiB

256 MiB 2048 KiB

512 MiB 2896 KiB

1024 MiB 4096 KiB

2048 MiB 5792 KiB

4096 MiB 8192 KiB

8192 MiB 11584 KiB

16384 MiB 16384 KiB

init_per_zone_pages_min

setup_per_zone_pages_min

setup_per_zone_lowmem_reserve

Figure 3-5: Code flow diagram for
init_per_zone_pages_min.

The lower bound for highmem zones,SWAP_CLUSTER_MAX, is an important quantity for the whole page
reclaim subsystem as discussed in Chapter 17. The code there often operates batchwise on page clusters,
andSWAP_CLUSTER_MAXdefines the size of such clusters. Figure 3-4 shows the outcome of the calcula-
tions for various main memory sizes. Since high memory is not very relevant anymore these days (most
machines with large amounts of RAM use 64-bit CPUs), I have restricted the graph to show the outcomes
for regular zones.

Computinglowmem_reserveis done insetup_per_zone_lowmem_reserve. The kernel iterates over all
nodes of the system and calculates the minimum reserve for each zone of the node by dividing the total
number of page frames in the zone bysysctl_lowmem_reserve_ratio[zone]. The default settings for
the divisor are 256 for low memory and 32 for high memory.

Reserving Pages


Thepagesetelement ofstruct zoneis used to implement a hot-n-cold allocator. The kernel refers to
apageinmemoryashotif it is in a CPU cache and its data can therefore be accessed quicker than if
Free download pdf