Linux Kernel Architecture

(Jacob Rumans) #1

Chapter3:MemoryManagement


Reservation is implemented in a CPU-independent way on UMA systems (NUMA systems employ
architecture-specific solutions). Thebootmem_datastructure is defined as follows:

<bootmem.h>
typedef struct bootmem_data {
unsigned long node_boot_start;
unsigned long node_low_pfn;
void *node_bootmem_map;
unsigned long last_offset;
unsigned long last_pos;
unsigned long last_success;

struct list_head list;
} bootmem_data_t;

When I use the termpagebelow, I always mean a physical page frame.

❑ node_boot_startholds the number of the first page in the system; this is zero for most architec-
tures.
❑ node_low_pfnis the number of the last page of the physical address space that can be managed
directly; in other words, it is the end ofZONE_NORMAL.
❑ node_bootmem_mapis a pointer to the memory area in which the allocation bitmap is stored. On
IA-32 systems, the memory area immediately following the kernel image is used for this pur-
pose. The corresponding address is held in the_endvariable, which is automatically patched
into the kernel image during linking.
❑ last_posis the number of the page last allocated.last_offsetis used as an offset within the
page if not all of the page memory was requested. This enables the bootmem allocator to assign
memory areas that are smaller than a complete page (the buddy system cannot do this).
❑ last_successspecifies the point in the bitmap at which allocation was last successful and is
used as the starting point for new reservations. Although this makes the first-fit algorithm a little
faster, it is still no real substitute for more sophisticated techniques.
❑ Systems with discontinuous memory can require more than one bootmem allocator. This is typ-
ically the case on NUMA machines that register one bootmem allocator per node, but it would,
for instance, also be possible to register one bootmem allocator for each continuous memory
region on systems where the physical address space is interspersed with holes.
A new boot allocator is registered withinit_bootmem_core, and the list of all registered alloca-
tors is headed by the global variablebdata_list.

On UMA systems, the singlebootmem_tinstance required is calledcontig_bootmem_data. It is associated
withcontig_page_databy means of thebdataelement.

mm/page_alloc.c
static bootmem_data_t contig_bootmem_data;
struct pglist_data contig_page_data = { .bdata = &contig_bootmem_data };

Initialization


Initializing the bootmem allocator is an architecture specific process that additionally depends on
the memory layout of the machine in question. As discussed above, IA-32 usessetup_memory,
Free download pdf