Page 432 - DCAP103_Principle of operating system
P. 432
Unit 14: Case Study of Linux Operating System
14.4.4 Physical Memory Management Notes
Due to idiosyncratic hardware limitations on many systems, not all physical memory can be
treated identically. Linux distinguishes between three memory zones:
1. ZONE_ DMA — pages that can be used for DMA operations.
2. ZONE_ NORMAL — normal, regularly-mapped pages.
3. ZONE_ HIGHMEM — pages with high memory addresses, which are not permanently mapped.
The exact boundaries and layout of the memory zones is architecture dependent. On x86
hardware, certain devices can perform DMA operations only in the first 16 MB of address
space, hence ZONE_ DMA is in the range 0–16 MB. In addition, the hardware cannot directly
map memory addresses above 896 MB, hence ZONE_ HIGHMEM is anything above this mark.
ZONE_ NORMAL is anything in between. Therefore, on x86 platforms, the first 896 MB of the
Linux address space are directly mapped, whereas the remaining 128 MB of the kernel address
space are used to access high memory regions. The kernel maintains a zone structure for each
of the three zones, and can perform memory allocations for the three zones separately.
Main memory in Linux consists of three parts. The first two parts, the kernel and memory map, are
pinned in memory (i.e., never paged out). The rest of memory is divided into page frames, each of
which can contain a text, data, or stack page, a page table page, or be on the free list. The
kernel maintains a map of the main memory which contains all information about the use of
the physical memory in the system, such as its zones, free page frame s, etc. The information
is organized as follows. First of all, Linux maintains an array of page descriptors, of type page
for each physical page frame in the system, called mem_ map. Each page descriptor contains a
pointer to the address space it belongs to, in case the page is not free, a pair of pointers which
allow it to form doubly-linked lists with other descriptors, for instance to keep together all free
page frames, and few other fields. In Figure 14.15, the page descriptor for page 150 contains a
mapping to the address.
Figure 14.15: Linux Main Memory Representation
Mem_map: array
of page descriptor
Physical memory
200
150 Mapping address_space
200–1 free page
60
70
150– mapped
free_pages
page_low
pages_high
... 80– free page
Zone_Highmem free area
free_ [1]
Zone_Normal ...
active_list 70– free page
Zone_DNA inactive_list
name
zone descriptor
mode_zones[3]
node_mem_map
mode_d
node descriptor
LOVELY PROFESSIONAL UNIVERSITY 425