Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 965
ritter Avatar asked Oct 30 '11 12:10

ritter


2 Answers

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.

like image 164
jpalecek Avatar answered Sep 21 '22 17:09

jpalecek


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

like image 21
Mat Avatar answered Sep 21 '22 17:09

Mat