Why are the PAGE_SIZE and the physical page frame size different in x86_64 kernel?
Hi, 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! Regards, Hao Lee
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.
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. Many Thanks! This explanation helps me a lot. I didn't know 4KB and 2MB page frames can exist at the same time:)
Regards, Hao Lee
participants (2)
-
Hao Lee -
valdis.kletnieks@vt.edu