【Linux 内核 内存管理】内存映射相关数据结构 ③ ( vm_area_struct 结构体成员分析 | shared 成员 | anon_vma_chain 成员 | anon_vma 成员 )
文章目录
- 一、vm_area_struct 结构体成员分析
- 1、shared 成员
- 2、anon_vma_chain 成员
- 3、anon_vma 成员
- 二、vm_area_struct 结构体完整源码
在博客 【Linux 内核 内存管理】虚拟地址空间布局架构 ⑦ ( vm_area_struct 结构体成员分析 | vm_start | vm_end | vm_next | vm_prev |vm_rb) 中 , 分析了 vm_start
vm_end
vm_next
vm_prev
vm_rb
这 555 个结构体成员作用 ;
在博客 【Linux 内核 内存管理】内存映射相关数据结构 ② ( vm_area_struct 结构体成员分析 | vm_mm 成员 | vm_page_prot 成员 | vm_flags 成员 ) 中 , 分析了 vm_area_struct
结构体中的 vm_mm
vm_page_prot
vm_flags
成员作用 ;
一、vm_area_struct 结构体成员分析
1、shared 成员
在 内存映射 中的 " 文件映射 " 中 , 将 " 文件 " 映射到 " 用户虚拟地址空间 " 后 , 需要将该文件的 地址空间结构 address_space
的成员 i_mmap
指针指向的 " 区域树 " 加入到该 shared 结构体中 ;
shared
成员中 , 可以查询 文件 的 哪些 " 文件区间的数据 " , 被映射到了 哪些 " 虚拟内存区域 " 中 ;
/** For areas with an address space and backing store,* linkage into the address_space->i_mmap interval tree.*/struct {struct rb_node rb;unsigned long rb_subtree_last;} shared;
2、anon_vma_chain 成员
" 虚拟内存区域 “ vm_area_struct
结构体实例 所 ” 关联 " 的 anon_vma
实例 ,
会与 " 父进程 " 的 anon_vma
实例 串联起来 , 组成一个 链表 ;
struct list_head anon_vma_chain
成员 就是该 anon_vma
实例 组成的 链表 ;
/** A file's MAP_PRIVATE vma can be in both i_mmap tree and anon_vma* list, after a COW of one of the file pages. A MAP_SHARED vma* can only be in the i_mmap tree. An anonymous MAP_PRIVATE, stack* or brk vma (with NULL file) can only be in an anon_vma list.*/struct list_head anon_vma_chain; /* Serialized by mmap_sem &* page_table_lock */
3、anon_vma 成员
anon_vma
结构体 用于 组织 " 匿名内存页 " 被 映射到的 " 用户虚拟地址空间 " ,
anon_vma
成员指向了 anon_vma
结构体实例 ;
struct anon_vma *anon_vma; /* Serialized by page_table_lock */
二、vm_area_struct 结构体完整源码
vm_area_struct
结构体完整源码 :
/** This struct defines a memory VMM memory area. There is one of these* per VM-area/task. A VM area is any part of the process virtual memory* space that has a special rule for the page-fault handlers (ie a shared* library, the executable area etc).*/
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 addresswithin vm_mm. *//* linked list of VM areas per task, sorted by address */struct vm_area_struct *vm_next, *vm_prev;struct rb_node vm_rb;/** Largest free memory gap in bytes to the left of this VMA.* Either between this VMA and vma->vm_prev, or between one of the* VMAs below us in the VMA rbtree and its ->vm_prev. This helps* get_unmapped_area find a free area of the right size.*/unsigned long rb_subtree_gap;/* Second cache line starts here. */struct mm_struct *vm_mm; /* The address space we belong to. */pgprot_t vm_page_prot; /* Access permissions of this VMA. */unsigned long vm_flags; /* Flags, see mm.h. *//** For areas with an address space and backing store,* linkage into the address_space->i_mmap interval tree.*/struct {struct rb_node rb;unsigned long rb_subtree_last;} shared;/** A file's MAP_PRIVATE vma can be in both i_mmap tree and anon_vma* list, after a COW of one of the file pages. A MAP_SHARED vma* can only be in the i_mmap tree. An anonymous MAP_PRIVATE, stack* or brk vma (with NULL file) can only be in an anon_vma list.*/struct list_head anon_vma_chain; /* Serialized by mmap_sem &* page_table_lock */struct anon_vma *anon_vma; /* Serialized by page_table_lock *//* Function pointers to deal with this struct. */const struct vm_operations_struct *vm_ops;/* Information about our backing store: */unsigned long vm_pgoff; /* Offset (within vm_file) in PAGE_SIZEunits */struct file * vm_file; /* File we map to (can be NULL). */void * vm_private_data; /* was vm_pte (shared mem) */#ifndef CONFIG_MMUstruct vm_region *vm_region; /* NOMMU mapping region */
#endif
#ifdef CONFIG_NUMAstruct mempolicy *vm_policy; /* NUMA policy for the VMA */
#endifstruct vm_userfaultfd_ctx vm_userfaultfd_ctx;
};
【Linux 内核 内存管理】内存映射相关数据结构 ③ ( vm_area_struct 结构体成员分析 | shared 成员 | anon_vma_chain 成员 | anon_vma 成员 )相关推荐
- Linux内核如何管理内存
在学习了进程的 虚拟地址布局 之后,让我们回到内核,来学习它管理用户内存的机制.这里再次使用 Gonzo: Linux kernel mm_struct Linux 进程在内核中是作为进程描述符 ta ...
- linux内核的I2C子系统详解2——关键结构体、关键文件
以下内容源于朱有鹏<物联网大讲堂>课程的学习,如有侵权,请告知删除. 3.I2C子系统的4个关键结构体 (1)struct i2c_adapter :I2C适配器 用来描述I2C控制器的, ...
- 详细讲解Linux内核源码内存管理(值得收藏)
Linux的内存管理是一个非常复杂的过程,主要分成两个大的部分:内核的内存管理和进程虚拟内存.内核的内存管理是Linux内存管理的核心,所以我们先对内核的内存管理进行简介. 一.物理内存模型 物理内存 ...
- Linux内存管理内存映射以及通过反汇编定位内存错误问题
提到C语言,我们知道C语言和其他高级语言的最大的区别就是C语言是要操作内存的! 我们需要知道--变量,其实是内存地址的一个抽像名字罢了.在静态编译的程序中,所有的变量名都会在编译时被转成内存地址.机器 ...
- Linux内核初始化阶段内存管理的几种阶段
本系列旨在讲述从引导到完全建立内存管理体系过程中,内核对内存管理所经历的几种状态.阅读本系列前,建议先阅读memblock的相关文章. 一些讲在前面的话 在很久很久以前,linux内核还是支持直接从磁 ...
- [十月往昔]——Linux内核中的内存管理浅谈
为什么要叫做"十月往昔"呢,是为了纪念我的原博客,http://www.casual0402.cn. 不知道为什么,突然想来一个新的开始--而那个博客存活至今刚好十个月,也有十个月 ...
- linux内核工程导论,Linux内核工程导论——内存管理(3)
Linux内核工程导论--内存管理(三) 用户端内核内存参数调整 /proc/sys/vm/ (需要根据内核版本调整) 交换相关 swap_token_timeout Thisfile contain ...
- Linux kernel内存管理之OOM相关参数
一.OOM概念 OOM是Out Of Memory(内存溢出)的缩写,虽然linux kernel的内存管理有很多机制(从cache中回收.swap out等)可以满足用户空间的各种虚拟内存需求,但是 ...
- 纯干货,linux内存管理——内存管理架构(建议收藏)
一.内存管理架构 内存管理子系统架构可以分为:用户空间.内核空间及硬件部分3个层面,具体结构如下所示: 1.用户空间:应用程序使用malloc()申请内存资源/free()释放内存资源. 2.内核空间 ...
最新文章
- 网站推广专员浅析网站建设实用技巧助力网站推广优化
- python模块批量安装方法_python离线批量安装依赖包
- [IE 技巧] 显示/隐藏IE 的菜单/工具栏
- mysql run sql files_如何在Eclipse DTP中運行多個.sql文件
- Asp.Net Core EndPoint 终结点路由工作原理解读
- Linux 内核中的宏定义
- Python-将一个列表的数据复制到另一个列表中
- Google新项目:从一条线开始,完成地球的绘制
- 数据仓库专题(16)-分布式数据仓库实践指南-目录篇
- 新手菜鸟防***必备知识
- 2021年12月最新大数据白皮书(附下载)
- ffmpeg之H265解码
- wav转mp3 c语言源码,C/C++知识点之mp3格式转wav格式 附完整C++算法实现代码
- 千帆竞发势如虹 明光政策送东风 首届明光大赛来了
- SAP中的client
- shel脚本中批量替换文件名
- 刘备当年是如何面试诸葛亮的?
- CCF201809-4 再卖菜
- 中药复方在治疗慢性盆腔炎上的应用
- 被迫营业:如何使用向日葵进行远程桌面控制(含MacOS)