/proc/cpuinfo 地址大小信息与内存页大小有何关系?
标记为 -lm 的 cpu 上的 cat /proc/cpuinfo 给出
address sizes : 36 bits physical, 48 bits virtual
由 Gives 4096 bytes 确定的页面大小
#include <unistd.h>
int getpagesize(void);
。
使用后一个信息,我会认为系统使用地址的最低有效 12 位作为偏移量,其余部分通过 TLB 和页表将虚拟地址转换为物理地址。
cpuinfo 中的信息与页面大小有何关系?
cat /proc/cpuinfo on a cpu flagged -lm gives
address sizes : 36 bits physical, 48 bits virtual
the page size determined with
#include <unistd.h>
int getpagesize(void);
Gives 4096 bytes.
Using the latter information I would have thought that the system uses the least significant 12 bits of an address as offset and the rest for address translation virtual to physical via TLB and page table.
How does the information from cpuinfo relate to page size?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是无关的。物理地址大小基本上给出了 CPU 拥有的地址线数量 (36)。虚拟地址大小为您提供虚拟地址空间的大小,即单个程序可以寻址的内存量(它是 48 位,这意味着它可以寻址超过物理内存量;它可以乘以虚拟地址空间)。页大小为 2^12,这意味着,正如您所指出的,其余虚拟地址位(36,不是物理地址空间中的 36)由 TLB 和分页机制处理。
It's unrelated. The physical address size gives you basically the number of address lines the CPU has (36). The virtual address size gives you the size of the virtual address space, that is how much memory a single program can address (it's 48 bits, which means it can address more than the amount of physical memory; it could be eg. multiplicated in the virtual address space). The page size is 2^12, which means, as you noted, the rest of the virtual address bits (36, which is not the 36 in physical address space) is handled by the TLB and paging mechanism.
事实并非如此。 x86_64 上的页面大小可以是 4k、2M(甚至 1G),无论(物理或虚拟)“地址大小”如何。
x86_64
的 Wikipedia 条目提供了一些有关如何实现的信息虚拟地址空间有效。映射不是按照您描述的方式完成的,而是使用四级页表完成的。 LWN.net 上的这篇文章:四级页表 详细介绍了它的工作原理以及为什么需要它。 (本文更多地讨论了三级地图,但第四级只是该方案的扩展)。
It doesn't. Page size on x86_64 can be 4k, 2M (or even 1G) regardless of the (physical or virtual) "address size".
The Wikipedia entry for
x86_64
has some information about how the virtual address space works.The mapping is not done the way you describe it, but with a four-level page table. This article on LWN.net: Four-level page tables has a run-down on how it works and why it is needed. (The article talks more about the three level map, but the fourth level is just an extension to that scheme).
cpuinfo 显示处理器类型和功能。
此处不显示系统当前使用的系统内存页大小。
现代 CPU 支持不同的页面大小,并且操作系统在启动时设置这些设置。
所以回答你的问题:cpuinfo中的信息与当前页面大小没有直接关系。使用处理器类型,您可以知道支持哪些页面大小。例如,ia32 PAE 扩展允许 2MB 页面(以及 4k 页面)。
cpuinfo displays the processor type and features.
The system memory page size currently used on your system is not displayed there.
Modern CPUs support different page sizes and the OS sets these settings on boot.
So to answer your question: the information in cpuinfo does not directly relate to current page size. Using the processor type you can know which page sizes are supported. For example ia32 PAE extension allows for 2MB pages (as well as 4k pages).