内存管理小结--全局变量
Posted yangjiguang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了内存管理小结--全局变量相关的知识,希望对你有一定的参考价值。
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;
以上是关于内存管理小结--全局变量的主要内容,如果未能解决你的问题,请参考以下文章
C#-WebForm-★内置对象简介★Request-获取请求对象Response相应请求对象Session全局变量(私有)Cookie全局变量(私有)Application全局公共变量Vi(代码片段