Why are the PAGE_SIZE and the physical page frame size different in x86_64 kernel?

valdis.kletnieks at vt.edu valdis.kletnieks at vt.edu
Thu Mar 29 13:12:45 EDT 2018


On Thu, 29 Mar 2018 22:48:24 +0800, Hao Lee said:
> I'm confused about the meaning of the PAGE_SIZE macro in x86_64
> kernel. Its value is 4KB and I once thought it was the size of a
> physical page frame, but now I think I'm wrong. I find that most of
> the physical address space is mapped by PMD entries, which means the
> actual physical page frame size is 2MB. Could someone explain why the
> PAGE_SIZE is not 2MB in x86_64 kernel? Thanks!

It's 4K for most things because using a fairly small page size is useful for
pages that are likely to swap out.  If the entire system used a 2MB page size,
then each page fault would require the writing of 2MB out, and then reading 2MB
back in.

> mapped by PMD entries, which means the actual physical page frame size is 2MB

Look closer.  Each entry in a PMD table covers 2M - and either describes a 2M
hugepage, or is a pointer to a table of PTE entries, each of which describes a
4K page.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 486 bytes
Desc: not available
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20180329/51b18b3a/attachment.sig>


More information about the Kernelnewbies mailing list