內存管理小結(1)--全局變量
阿新 • • 發佈:2018-08-26
賦值 1.4 變量 mos memmap offset _id sig hole
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)--全局變量