Linux Kernel Architecture

(Jacob Rumans) #1

Chapter3:MemoryManagement


If page mobility has been disabled, all pages will be kept in the unmovable zone. Otherwise, the return
value of the function can be directly used as an array index infree_area.free_list.

Finally, note that each memory zone provides a special field that allows for tracking properties of page
blocks withpageblock_nr_pagespages. Since this is currently only used by the page mobility code, I
have not introduced this feature before:

<mmzone.h>
struct zone {
...
unsigned long *pageblock_flags;
...
}

During initialization, the kernel automatically ensures that for each page block group in the zone, suf-
ficient space is available inpageblock_flagsto storeNR_PAGEBLOCK_BITSbits. Currently, 3 bits are
required to denote the migrate type of the page range:

<pageblock-flags.h>
/* Macro to aid the definition of ranges of bits */
#define PB_range(name, required_bits) \
name, name ## _end = (name + required_bits) - 1

/* Bit indices that affect a whole block of pages */
enum pageblock_bits {
PB_range(PB_migrate, 3), /* 3 bits required for migrate types */
NR_PAGEBLOCK_BITS
};

set_pageblock_migratetypeis responsible to set the migrate type for a page block headed bypage:

mm/page_alloc.c
void set_pageblock_migratetype(struct page *page, int migratetype)

Themigratetypeargument can be constructed by the auxiliary functionallocflags_to_migratetype
introduced above. Notice that it is essential that the migrate type of a page is always preserved and not
just available when the page is located in the buddy system. When memory is released, the pages must
be put back to the proper migrate list, and this is only possible because the required information can be
obtained withget_pageblock_migratetype.

Finally, notice that the current state of page distribution across the migrate lists can be found in
/proc/pagetypeinfo:

wolfgang@meitner>cat /proc/pagetypeinfo
Page block order: 9
Pages per block: 512

Free download pdf