Reputation: 439
On x86 machines with highmem, when the kernel wants to query the kernel virtual address of a physical frame, it will use page_address
. How it works depends on whether the macro WANT_PAGE_VIRTUAL is defined, which decides if void *virtual
is added in struct page
. If there is no void *virtual
, the kernel will use a hash table page_address_htable
to do the conversion, and this seems the method x86 applies. On the contrary, mips and m68k just take void *virtual
(I'm not very sure for this).
So my question is, why x86 prefers a hash table to a improved struct page
? What are the benefits it brings about?
Upvotes: 5
Views: 763
Reputation: 6583
Since there are a lot of struct page
needed (one for every page!) it is very expensive to add even one more word to the structure (or conversely, shrinking the struct by even one word gives a lot of benefit). On 32-bit architectures WANT_PAGE_VIRTUAL
is especially expensive -- without it, struct page is exactly 32 bytes, which means it packs nicely into cachelines etc.
On x86 the hash lookup is fast enough (since multiplication is fast on x86) that the tradeoff is strongly in favor of making struct page smaller. I guess on m68k multiplication is expensive enough that bloating struct page to 36 bytes is worth it.
Upvotes: 7