1.定义
在mm/memory.c文件中定义
- mm/memory.c
- 70 #ifndef CONFIG_NEED_MULTIPLE_NODES
- 71 /* use the per-pgdat data instead for discontigmem - mbligh */
- 72 unsigned long max_mapnr;
- 73 struct page *mem_map;
- 74
- 75 EXPORT_SYMBOL(max_mapnr);
- 76 EXPORT_SYMBOL(mem_map);
- 77 #endif
2.在哪里被初始化
在mm/page_alloc.c文件中的alloc_node_mem_map函数被初始化。
- mm/page_alloc.c
- 4146 static void __init_refok alloc_node_mem_map(struct pglist_data *pgdat)
- 4147 {
- 4148 /* Skip empty nodes */
- 4149 if (!pgdat->node_spanned_pages)
- 4150 return;
- 4151
- 4152 #ifdef CONFIG_FLAT_NODE_MEM_MAP
- 4153 /* ia64 gets its own node_mem_map, before this, without bootmem */
- 4154 if (!pgdat->node_mem_map) {
- 4155 unsigned long size, start, end;
- 4156 struct page *map;
- 4157
- 4158 /*
- 4159 * The zone's endpoints aren't required to be MAX_ORDER
- 4160 * aligned but the node_mem_map endpoints must be in order
- 4161 * for the buddy allocator to function correctly.
- 4162 */
- 4163 start = pgdat->node_start_pfn & ~(MAX_ORDER_NR_PAGES - 1);
- 4164 end = pgdat->node_start_pfn + pgdat->node_spanned_pages;
- 4165 end = ALIGN(end, MAX_ORDER_NR_PAGES);
- 4166 size = (end - start) * sizeof(struct page);
- 4167 map = alloc_remap(pgdat->node_id, size);
- 4168 if (!map)
- 4169 map = alloc_bootmem_node(pgdat, size);
- 4170 pgdat->node_mem_map = map + (pgdat->node_start_pfn - start);
- 4171 }
- 4172 #ifndef CONFIG_NEED_MULTIPLE_NODES
- 4173 /*
- 4174 * With no DISCONTIG, the global mem_map is just set as node 0's
- 4175 */
- 4176 if (pgdat == NODE_DATA(0)) {
- 4177 mem_map = NODE_DATA(0)->node_mem_map;
- 4178 #ifdef CONFIG_ARCH_POPULATES_NODE_MAP
- 4179 if (page_to_pfn(mem_map) != pgdat->node_start_pfn)
- 4180 mem_map -= (pgdat->node_start_pfn - ARCH_PFN_OFFSET);
- 4181 #endif /* CONFIG_ARCH_POPULATES_NODE_MAP */
- 4182 }
- 4183 #endif
- 4184 #endif /* CONFIG_FLAT_NODE_MEM_MAP */
- 4185 }
3.从start_kernel函数调用alloc_node_mem_map函数的流程
start_kernel(init/main.c)->setup_arch(arch/arm/kernel/setup.c)->paging_init(arch/arm/mm/mmu.c)->bootmem_init(arch/arm/mm/init.c)->bootmem_free_node(arch/arm/mm/init.c)
->free_area_init_node(mm/page_alloc.c)->alloc_node_mem_map(mm/page_alloc.c)
阅读(835) | 评论(0) | 转发(0) |