Android系统中添加内存分区(Zone)
来源:互联网 发布:机制和体制的区别知乎 编辑:程序博客网 时间:2024/05/18 00:22
1. 添加zone_type枚举类型
//路径: include/linux/Mmzone.henum zone_type {#ifdef CONFIG_ZONE_DMA/* * ZONE_DMA is used when there are devices that are not able * to do DMA to all of addressable memory (ZONE_NORMAL). Then we * carve out the portion of memory that is needed for these devices. * The range is arch specific. * * Some examples * * ArchitectureLimit * --------------------------- * parisc, ia64, sparc<4G * s390<2G * armVarious * alphaUnlimited or 0-16MB. * * i386, x86_64 and multiple other arches * <16M. */ZONE_DMA,#endif#ifdef CONFIG_ZONE_DMA32/* * x86_64 needs two ZONE_DMAs because it supports devices that are * only able to do DMA to the lower 16M but also 32 bit devices that * can only do DMA areas below 4G. */ZONE_DMA32,#endif/* * Normal addressable memory is in ZONE_NORMAL. DMA operations can be * performed on pages in ZONE_NORMAL if the DMA devices support * transfers to all addressable memory. */ZONE_NORMAL, ZONE_MEMSWAP,#ifdef CONFIG_HIGHMEM/* * A memory area that is only addressable by the kernel through * mapping portions into its own address space. This is for example * used by i386 to allow the kernel to address the memory beyond * 900MB. The kernel will set up special mappings (page * table entries on i386) for each page that the kernel needs to * access. */ZONE_HIGHMEM,#endifZONE_MOVABLE,__MAX_NR_ZONES};
其中
ZONE_MEMSWAP,即为添加zone对应的枚举类型
2. 修改内存初始化代码
//路径 arch/arm/mm/Init.cstatic void __init arm_bootmem_free(unsigned long min, unsigned long max_low,unsigned long max_high)添加代码
unsigned long mem_swap_size = 1UL << 15; unsigned long normal_start = min, normal_end = max_low - mem_swap_size;
zone_size[0] = normal_end - normal_start;zone_size[ZONE_MEMSWAP] = mem_swap_size;
#ifdef CONFIG_HIGHMEMzone_size[ZONE_HIGHMEM] = max_high - max_low;#endif
zhole_size[ZONE_MEMSWAP] = 0UL;for_each_memblock(memory, reg) {unsigned long start = memblock_region_memory_base_pfn(reg);unsigned long end = memblock_region_memory_end_pfn(reg);if (start < normal_end) {unsigned long low_end = min(end, normal_end);zhole_size[0] -= low_end - start;}
#ifdef CONFIG_HIGHMEMif (end > max_low) {unsigned long high_start = max(start, max_low);zhole_size[ZONE_HIGHMEM] -= end - high_start;}#endif
3. 修改内存分配代码
//路径:mm/page_alloc.cget_page_from_freelist(gfp_t gfp_mask, nodemask_t *nodemask, unsigned int order,struct zonelist *zonelist, int high_zoneidx, int alloc_flags,struct zone *preferred_zone, int migratetype)
在上面函数的下述for循环开头添加如下代码:
for_each_zone_zonelist_nodemask(zone, z, zonelist,high_zoneidx, nodemask) {... if (zone_idx(zone) == ZONE_MEMSWAP) continue;...}
<pre name="code" class="cpp">同样是该路径的该函数:static char * const zone_names[MAX_NR_ZONES] = {#ifdef CONFIG_ZONE_DMA "DMA",#endif#ifdef CONFIG_ZONE_DMA32 "DMA32",#endif "Normal", "MemSwap",#ifdef CONFIG_HIGHMEM "HighMem",#endif "Movable",};
0 0
- Android系统中添加内存分区(Zone)
- C++中系统内存分区与程序内存分区
- C++中系统内存分区与程序内存分区
- C++中系统内存分区与程序内存分区
- ZONE分区(BROCADE的观点)
- Android系统手机内存卡分区详解
- 堆和栈:C++中系统内存分区与程序内存分区
- 浅析Linux系统中添加硬盘,分区,格式化
- Linux系统中添加硬盘,分区与格式化
- android分区添加
- 动态添加zone addzone
- android 系统分区
- 【android】系统分区相关
- Android 系统分区分析
- android系统分区
- Android系统分区理解
- Android系统分区
- Android系统分区
- 允许进行DML操作的视图条件
- 算法设计分析:相邻最大矩形面积
- Mysql 存储过程 小解
- PBP,NPV,IRR,BEP分别是什么
- 曼哈顿距离 欧几里得距离 切比雪夫距离
- Android系统中添加内存分区(Zone)
- File中几种方法的运用
- TOJ 3365 It's not Floyd Algorithm -- 强连通分量 + floyd
- requireJs
- 使用Hibernate过滤集合元素的两种方法
- Ubuntu12.04 安装lamp环境
- BDS之数组与矩阵
- 95 Android 文件存储(1)
- 大公司凭什么收购你?