[英]How to get the physical address of a huge-page
I need to get the physical address of a huge-page (2 MB) from user-space. 我需要从用户空间获取大页面(2 MB)的物理地址。 I managed to get the physical address of a normal 4 KB page from pagemap as shown in https://shanetully.com/2014/12/translating-virtual-addresses-to-physcial-addresses-in-user-space/#codeprocpidpagemapcode however I don't understand how I should use pagemap to get the physical address of a huge-page.
我设法从页面地图获取正常4 KB页面的物理地址,如https://shanetully.com/2014/12/translating-virtual-addresses-to-physcial-addresses-in-user-space/#codeprocpidpagemapcode所示但是我不明白我应该如何使用pagemap来获取大页面的物理地址。 How is a huge-page page frame number represented in pagemap?
如何在页面映射中表示巨大的页面页框号? Any references and especially any piece of code would be highly appreciated.
任何参考,特别是任何代码都将受到高度赞赏。
It should be the same. 应该是一样的。 The primary difference between normal pages and huge pages are a few layers of the page tables.
普通页面和大页面之间的主要区别是页面表的几层。 The page table walk ends early for huge pages (at least on x86).
对于大页面(至少在x86上),页表行程提前结束。
Huge-pages generally end in more zeros than typical pages, as they need to be aligned to their size (in the 2MB case, the low 21 bits should all be zero). 巨页通常以比典型页面更多的零结束,因为它们需要与它们的大小对齐(在2MB的情况下,低21位应该都是零)。
If you are getting -EINVAL from your reads, check out this quote from the pagemap documentation (the example reads the wrong number of bytes): 如果从读取中获取-EINVAL,请从页面地图文档中查看此引用(该示例读取错误的字节数):
Reading from any of the files will return -EINVAL if you are not starting the read on an 8-byte boundary (eg, if you sought an odd number of bytes into the file), or if the size of the read is not a multiple of 8 bytes.
如果您没有在8字节边界上开始读取(例如,如果您在文件中寻找奇数个字节),或者如果读取的大小不是多个,则从任何文件读取将返回-EINVAL 8个字节。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.