how does /proc/cpuinfo address size information relates to memory page size?

StackOverflow https://stackoverflow.com/questions/7944793

  •  16-02-2021
  •  | 
  •  

سؤال

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?

هل كانت مفيدة؟

المحلول

How does the information from cpuinfo relate to page size?

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.

نصائح أخرى

How does the information from cpuinfo relate to page size?

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 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).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top