Data Structures

Reservation is implemented in a CPU-independent way on UMA systems (NUMA systems employ architecture-specific solutions). The bootmem_data structure 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 term page below, I always mean a physical page frame.

□ node_boot_start holds the number of the first page in the system; this is zero for most architectures.

□ node_low_pfn is the number of the last page of the physical address space that can be managed directly; in other words, it is the end of zone_normal.

□ node_bootmem_map is 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 purpose. The corresponding address is held in the _end variable, which is automatically patched into the kernel image during linking.

□ last_pos is the number of the page last allocated. last_offset is 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_success specifies 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 typically 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 with init_bootmem_core, and the list of all registered allocators is headed by the global variable bdata_list.

On UMA systems, the single bootmem_t instance required is called contig_bootmem_data. It is associated with contig_page_data by means of the bdata element.

mm/page_alloc.c static bootmem_data_t contig_bootmem_data;

struct pglist_data contig_page_data = { .bdata = &contig_bootmem_data };

Continue reading here: Initialization

Was this article helpful?

0 0