alloc_bootmem_low_pages()定义在:include/linux/bootmem.h中,定义如下:
#define alloc_bootmem_low_pages(x) \
__alloc_bootmem_low(x, PAGE_SIZE, 0)
__alloc_bootmem_low()定义在:mm/bootmem.c,定义如下:
查找bdata链表上的每个节点,这每个节点代表一个bitmap,当然x86默认配置上只有一个节点,该节点在bootmem allocator初始化时创建,并添加到这个链表中。void * __init __alloc_bootmem_low(unsigned long size, unsigned long align,
unsigned long goal)
{
bootmem_data_t *bdata;
void *ptr;
list_for_each_entry(bdata, &bdata_list, list) {
ptr = __alloc_bootmem_core(bdata, size, align, goal,
ARCH_LOW_ADDRESS_LIMIT);
if (ptr)
return ptr;
}
printk(KERN_ALERT "low bootmem alloc of %lu bytes failed!\n", size);
panic("Out of low memory");
return NULL;
}
核心函数还是__alloc_bootmem_core(),该函数定义于:mm/bootmem.c,定义如下:
void * __init
__alloc_bootmem_core(struct bootmem_data *bdata, unsigned long size,
unsigned long align, unsigned long goal, unsigned long limit)
{
unsigned long offset, remaining_size, areasize, preferred;
unsigned long i, start = 0, incr, eidx, end_pfn;
void *ret;if (!size) {
printk("__alloc_bootmem_core(): zero-sized request\n");
BUG();
}
BUG_ON(align & (alig