当前位置:网站首页>匿名页的反向映射
匿名页的反向映射
2022-06-28 08:05:00 【HZero.chen】

反向映射的建立过程
当通过fork创建子进程的时候,在这个过程中会建立反向映射的基础结构,具体在
kernel_clone -》 copy_mm -》 dup_mm -》 dup_mmap中:
- dup_mmap中会将父进程中的每一个vma 复制一份给子进程,此处只是举例说明复制一个vma的情况,如上图中子进程的vma
- anon_vma_clone中创建子进程的avc01,它同时与父进程的av0和子进程的vma建立关联,即加入子进程的vma链表,同时连入父进程av0的红黑树,它是作为子进程的一个代表加入到父进程av0的红黑树,将来父进程查找反向映射时,将遍历这颗红黑树,进而获得vma,而子进程进行反向映射时,仅仅遍历自己av的红黑树即可,这样提升了效率;
- 通过anon_vma_alloc为子进程分配自己的av1,它与父进程的av0形成父子关系;
- 通过anon_vma_chain_alloc为子进程分配自己的avc1;
- 通过anon_vma_chain_link建立子进程av1, avc1, vma的关联
注:如上av为strucdt anon_vma, avc为anon_vma_chain
反向映射的查找过程
- 通过page的mapping字段找到av;
- 遍历av的红黑树,找到所有的avc;
- 通过avc找到对应的vma,并通过vma找到vma_start,及vm_mm进而找到pgd;
- 通过page->index和vma_start得到虚拟页的起始地址;
- 通过虚拟页的起始地址和pgd找到pte
参考文档
《Linux内核深度解析》
《深入理解Linux内核反向映射机制》
边栏推荐
猜你喜欢

asp. Net registration page

Uninstall and reinstall the latest version of MySQL database. The test is valid

Hash slot of rediscluster cluster cluster implementation principle

Vagrant installation

Jenkins' common build trigger and hook services (V)

Airflow2.1.1 summary of the pits stepped on in actual combat!!

SOC serial port configuration

Unity UI shadow component

Cloud native: cloud computing technology is upgraded again to open an era of comprehensive cloud development

MySQL two table connection principle (understand join buf)
随机推荐
asp. Net error "/" server error in the application. String or binary data would be truncated. The statement...
Configuring multiple instances of MySQL under Linux
Prometheus monitoring (I)
Configuring MySQL multi instance master-slave synchronization for Linux
ACM notes
SQL master-slave replication setup
Software testing and quality final review
Airflow2.1.1 ultra detailed installation document
Section VI UART of zynq
Is it reliable to register and open an account for stock speculation? Is it safe?
HJ character count
[JS] - [DFS, BFS application] - learning notes
Evaluation of inverse Polish expression < difficulty coefficient >
Conversion between HJ integer and IP address
Introduction to Devops Basics
ROS 笔记(08)— 服务数据的定义与使用
Airflow2.1.1 summary of the pits stepped on in actual combat!!
Helloword routine for ROS
【js】-【DFS、BFS应用】-学习笔记
How to use redis to solve concurrency problems