初始化pg_data_t->bdtat结构体,
/* * node_bootmem_map is a map pointer - the bits represent all physical * memory pages (including holes) on the node. */ typedef struct bootmem_data { unsigned long node_min_pfn; unsigned long node_low_pfn; void *node_bootmem_map; unsigned long last_end_off; unsigned long hint_idx; struct list_head list; } bootmem_data_t;
将不同node的bdata添加到以bdata_list为首的链表。
标记所有的bitmap位为1。
unsigned long __init init_bootmem_node(pg_data_t *pgdat, unsigned long freepfn, unsigned long startpfn, unsigned long endpfn) -->init_bootmem_core(pgdat->bdata, freepfn, startpfn, endpfn); -->link_bootmem(bdata); /*标记所有内存页框为1,已使用*/ -->mapsize = bootmap_bytes(end - start); -->memset(bdata->node_bootmem_map, 0xff, mapsize);
/* * Called once to set up the allocator itself. */ static unsigned long __init init_bootmem_core(bootmem_data_t *bdata, unsigned long mapstart, unsigned long start, unsigned long end) { unsigned long mapsize; mminit_validate_memmodel_limits(&start, &end); bdata->node_bootmem_map = phys_to_virt(PFN_PHYS(mapstart)); bdata->node_min_pfn = start; bdata->node_low_pfn = end; link_bootmem(bdata); /* * Initially all pages are reserved - setup_arch() has to * register free RAM areas explicitly. */ mapsize = bootmap_bytes(end - start); memset(bdata->node_bootmem_map, 0xff, mapsize); bdebug("nid=%td start=%lx map=%lx end=%lx mapsize=%lx ", bdata - bootmem_node_data, start, mapstart, end, mapsize); return mapsize; }