【Linux 内核 内存管理】memblock 分配器 ① ( memblock 分配器简介 | memblock 结构体成员分析 | 物理内存类型 与 内存类型 )





一、memblock 分配器



memblock 分配器 定义在 Linux 内核源码的 linux-4.12\include\linux\memblock.h#48 位置 ;

struct memblock {
    
    
	bool bottom_up;  /* is bottom up direction? */
	phys_addr_t current_limit;
	struct memblock_type memory;
	struct memblock_type reserved;
#ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP
	struct memblock_type physmem;
#endif
};

源码路径 : linux-4.12\include\linux\memblock.h#48

在这里插入图片描述





二、memblock 结构体分析




1、bottom_up 成员


bottom_up 成员表示 内存分配方式 ,

  • TRUE , 表示 从 " 低地址向上分配 " ,
  • FALSE , 表示 从 " 高地址向下分配 " ;
	bool bottom_up;  /* is bottom up direction? */

2、current_limit 成员


current_limit 成员表示 可分配内存的 最大物理地址 ;

	phys_addr_t current_limit;

3、memory 成员


memory 成员 表示 内存类型 , 该内存 包括 已分配 和 未分配 的内存 ;

	struct memblock_type memory;

4、reserved 成员


reserved 成员 表示 预留类型 , 该内存只包含 已分配内存 ;

	struct memblock_type reserved;

5、physmem 成员


physmem 成员 表示 物理内存类型 ;

#ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP
	struct memblock_type physmem;
#endif




三、物理内存类型 与 内存类型



物理内存类型 与 内存类型 :

  • 包含关系 : 物理内存类型 包含 内存类型 ;
  • 内存类型 : 在 内核 引导启动时 , 只能使用 mem 内核参数 指定可用内存大小范围 , 该范围之外的内存不可使用 , 即内核无法使用所有的内存 ;
  • 物理类型 : 包含所有的内存范围 ;

猜你喜欢

转载自blog.csdn.net/han1202012/article/details/124268254