Chinaunix首页 | 论坛 | 博客
  • 博客访问: 102175
  • 博文数量: 34
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 215
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-27 11:21
文章分类
文章存档

2014年(1)

2013年(33)

我的朋友

分类: LINUX

2013-07-30 16:18:03

1.定义
在mm/memory.c文件中定义
  1. mm/memory.c

  2.     70 #ifndef CONFIG_NEED_MULTIPLE_NODES
  3.     71 /* use the per-pgdat data instead for discontigmem - mbligh */
  4.     72 unsigned long max_mapnr;
  5.     73 struct page *mem_map;
  6.     74
  7.     75 EXPORT_SYMBOL(max_mapnr);
  8.     76 EXPORT_SYMBOL(mem_map);
  9.     77 #endif
 
2.在哪里被初始化
在mm/page_alloc.c文件中的alloc_node_mem_map函数被初始化。
  1. mm/page_alloc.c

  2. 4146 static void __init_refok alloc_node_mem_map(struct pglist_data *pgdat)
  3. 4147 {
  4. 4148 /* Skip empty nodes */
  5. 4149 if (!pgdat->node_spanned_pages)
  6. 4150 return;
  7. 4151
  8. 4152 #ifdef CONFIG_FLAT_NODE_MEM_MAP
  9. 4153 /* ia64 gets its own node_mem_map, before this, without bootmem */
  10. 4154 if (!pgdat->node_mem_map) {
  11. 4155 unsigned long size, start, end;
  12. 4156 struct page *map;
  13. 4157
  14. 4158 /*
  15. 4159 * The zone's endpoints aren't required to be MAX_ORDER
  16. 4160 * aligned but the node_mem_map endpoints must be in order
  17. 4161 * for the buddy allocator to function correctly.
  18. 4162 */
  19. 4163 start = pgdat->node_start_pfn & ~(MAX_ORDER_NR_PAGES - 1);
  20. 4164 end = pgdat->node_start_pfn + pgdat->node_spanned_pages;
  21. 4165 end = ALIGN(end, MAX_ORDER_NR_PAGES);
  22. 4166 size = (end - start) * sizeof(struct page);
  23. 4167 map = alloc_remap(pgdat->node_id, size);
  24. 4168 if (!map)
  25. 4169 map = alloc_bootmem_node(pgdat, size);
  26. 4170 pgdat->node_mem_map = map + (pgdat->node_start_pfn - start);
  27. 4171 }
  28. 4172 #ifndef CONFIG_NEED_MULTIPLE_NODES
  29. 4173 /*
  30. 4174 * With no DISCONTIG, the global mem_map is just set as node 0's
  31. 4175 */
  32. 4176 if (pgdat == NODE_DATA(0)) {
  33. 4177 mem_map = NODE_DATA(0)->node_mem_map;
  34. 4178 #ifdef CONFIG_ARCH_POPULATES_NODE_MAP
  35. 4179 if (page_to_pfn(mem_map) != pgdat->node_start_pfn)
  36. 4180 mem_map -= (pgdat->node_start_pfn - ARCH_PFN_OFFSET);
  37. 4181 #endif /* CONFIG_ARCH_POPULATES_NODE_MAP */
  38. 4182 }
  39. 4183 #endif
  40. 4184 #endif /* CONFIG_FLAT_NODE_MEM_MAP */
  41. 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)
阅读(2831) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~