你好,游客 登录 注册 搜索
背景:
阅读新闻

Linux节点和内存管理区的初始化

[日期:2012-05-13] 来源:Linux社区  作者:vanbreaker [字体:大 中 小]

至此,节点和管理区的关键数据已完成初始化,内核在后面为内存管理做得一个准备工作就是将所有节点的管理区都链入到zonelist中,便于后面内存分配工作的进行

内核在start_kernel()-->build_all_zonelist()中完成zonelist的初始化

  1. void build_all_zonelists(void)  
  2. {  
  3.     /*设定zonelist的顺序,是按节点还是按管理区排序,只对NUMA有意义*/  
  4.     set_zonelist_order();  
  5.   
  6.     if (system_state == SYSTEM_BOOTING) {  
  7.         __build_all_zonelists(NULL);  
  8.         mminit_verify_zonelist();  
  9.         cpuset_init_current_mems_allowed();  
  10.     } else {  
  11.         /* we have to stop all cpus to guarantee there is no user 
  12.            of zonelist */  
  13.         stop_machine(__build_all_zonelists, NULL, NULL);  
  14.         /* cpuset refresh routine should be here */  
  15.     }  
  16.     /*得到所有管理区可分配的空闲页面数*/  
  17.     vm_total_pages = nr_free_pagecache_pages();  
  18.     /* 
  19.      * Disable grouping by mobility if the number of pages in the 
  20.      * system is too low to allow the mechanism to work. It would be 
  21.      * more accurate, but expensive to check per-zone. This check is 
  22.      * made on memory-hotadd so a system can start with mobility 
  23.      * disabled and enable it later 
  24.      */  
  25.     if (vm_total_pages < (pageblock_nr_pages * MIGRATE_TYPES))  
  26.         page_group_by_mobility_disabled = 1;  
  27.     else  
  28.         page_group_by_mobility_disabled = 0;  
  29.   
  30.     printk("Built %i zonelists in %s order, mobility grouping %s.  "  
  31.         "Total pages: %ld\n",  
  32.             nr_online_nodes,  
  33.             zonelist_order_name[current_zonelist_order],  
  34.             page_group_by_mobility_disabled ? "off" : "on",  
  35.             vm_total_pages);  
  36. #ifdef CONFIG_NUMA   
  37.     printk("Policy zone: %s\n", zone_names[policy_zone]);  
  38. #endif   
  39. }  
 
  1. static int __build_all_zonelists(void *dummy)  
  2. {  
  3.     int nid;  
  4.   
  5. #ifdef CONFIG_NUMA   
  6.     memset(node_load, 0, sizeof(node_load));  
  7. #endif   
  8.     for_each_online_node(nid) {/*遍历节点*/  
  9.         pg_data_t *pgdat = NODE_DATA(nid);  
  10.   
  11.         build_zonelists(pgdat);  
  12.         build_zonelist_cache(pgdat);  
  13.     }  
  14.     return 0;  
  15. }  
linux
相关资讯       Linux入门教程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款