码迷,mamicode.com
首页 > 其他好文 > 详细

内存管理小结(1)--全局变量

时间:2018-08-26 22:01:03      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:初始化   str   als   min   ini   node   ati   mmap   流程   

1.全局变量赋值

1.1high_memory

void * high_memory; /*mm/memory.c*/

unsigned long max_low_pfn; /*mm/bootmem.c*/
unsigned long min_low_pfn;  /*mm/bootmem.c*/
unsigned long max_pfn;  /*mm/bootmem.c*/

以上全局变量在bootmem_init中赋值

void __init bootmem_init(void)
    -->high_memory = __va((memend_pfn << PAGE_SHIFT) - 1) + 1;
    -->max_pfn = max_low_pfn = memend_pfn - PHYS_PFN_OFFSET;

1.2mem_map

struct page *mem_map; /*mm/memory.c*/

赋值调用过程如下

void __init bootmem_init(void)
    -->bootmem_free_node(node, mi);
        -->free_area_init_node(node, zone_size, start_pfn, zhole_size);
            -->static void __init_refok alloc_node_mem_map(struct pglist_data *pgdat)
                -->mem_map = NODE_DATA(0)->node_mem_map;

1.3物理页框数统计

unsigned long __meminitdata nr_kernel_pages;  /*mm/page_alloc.c*/
unsigned long __meminitdata nr_all_pages;  /*mm/page_alloc.c*/

赋值调用流程

void __init bootmem_init(void)
    -->bootmem_free_node(node, mi);
        -->free_area_init_node(node, zone_size, start_pfn, zhole_size);
            -->free_area_init_core(pgdat, zones_size, zholes_size);
                -->if (!is_highmem_idx(j))
                    nr_kernel_pages += realsize;
                -->nr_all_pages += realsize

1.4highest_memmap_pfn,最大页框号

unsigned long highest_memmap_pfn __read_mostly; /*mm/page_alloc.c*/

赋值调用流程

void __init bootmem_init(void)
    -->bootmem_free_node(node, mi);
        -->free_area_init_node(node, zone_size, start_pfn, zhole_size);
            -->free_area_init_core(pgdat, zones_size, zholes_size);
                -->memmap_init(size, nid, j, zone_start_pfn);
                    -->memmap_init_zone((size), (nid), (zone), (start_pfn), MEMMAP_EARLY)
                        -->if (highest_memmap_pfn < end_pfn - 1)
                            highest_memmap_pfn = end_pfn - 1;

1.5totalram_pages,伙伴系统初始化完成后可用的ram总页数

unsigned long totalram_pages __read_mostly;  /*mm/page_alloc.c*/

void __init mem_init(void)
    -->totalram_pages += free_all_bootmem_node(pgdat);
    -->totalram_pages += totalhigh_pages;

 

内存管理小结(1)--全局变量

标签:初始化   str   als   min   ini   node   ati   mmap   流程   

原文地址:https://www.cnblogs.com/yangjiguang/p/9538909.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!