如何使在页表present一个过程的每一页面? [英] How to make every page of a process in the page table present?
问题描述
我编译在Linux上使用gcc和KVM下运行它的静态程序。我检查guest虚拟机内存每到这个进程的页表项,发现部分网页已被映射和一些的人都没有。这是按需分页的功能?我的问题是是否有一个解决方案,以使所有的私人present并在页表映射?
例如。我叉一个新的进程和加载新的ELF程序,如何在这种新工艺的页表映射的每一页。
谢谢
i compiled a static program using gcc on linux and run it under kvm. I checked every page table entry of this process in guest memory and found that some pages have been mapped and some ones are not. Is this the feature of on-demand paging? My question is whether there is a solution to make all the pte present and mapped in the page table? E.g. i fork a new process and load a new elf binary, how to make every page mapped in the page table of this new process. Thanks
推荐答案
试用以下的系统调用:
#include <sys/mman.h>
int mlockall(int flags);
设置与MCL_FUTURE flags参数,它会锁定所有当前和未来的页到内存中。你可以找到更多关于它这里或只需键入人mlockall用于你将获得大量信息。
Set the flags parameter with MCL_FUTURE and it will lock all current and future pages into memory. You can find more info about it here or just type "man mlockall" and you will get a bunch of information.
这篇关于如何使在页表present一个过程的每一页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!