vm_area_struct
linux 内核使用 vm_area_struct 结构来表示一个独立的虚拟内存区域,由于每个不同地址的虚拟内存区域功能和内部机制都不同,因此 一个进程使用多个vm_area_struct结构来分别表示不同类型的虚拟内存区域,包括虚拟内存的起始和结束地址,以及内存的访问权限等 。各个vm_area_struct结构使用链表或者树形结构链接,方便进程快速访问,如下图所示:
Linux内核中,关于虚存管理的 最基本的管理单元 应该是 struct vm_area_struct 了,它描述的是一段连续的、具有相同访问属性的虚存空间,该虚存空间的大小为物理内存页面的整数倍。
<include/linux/mm_types.h>
struct vm_area_struct {
/* The first cache line has the info for VMA tree walking. */
unsigned long vm_start; /* Our start address within vm_mm. */
unsigned long vm_end; /* The first byte after our end address
within vm_mm. */
/*[vm_start, vm_end) 这么个情况,表示一块虚拟内存空间*/
/* linked list of VM areas per task, sorted by address */
struct vm_area_struct *vm_next, *vm_prev;
/*在mm->mmap链表中前后节点*/
struct rb_node vm_rb;