Re: Merging Nonlinear and Numa style memory hotplug
From: Dave Hansen <hidden>
Date: 2004-06-24 22:40:29
Also in:
lkml
On Thu, 2004-06-24 at 15:19, Yasunori Goto wrote:
BTW, I have a question about nonlinear patch. It is about difference between phys_section[] and mem_section[] I suppose that phys_section[] looks like no-meaning now. If it isn't necessary, __va() and __pa() translation can be more simple. What is the purpose of phys_section[]. Is it for ppc64?
This is the fun (read: confusing) part of nonlinear.
The mem_section[] array is where the pointer to the mem_map for the
section is stored, obviously. It's indexed virtually, so that something
at a virtual address is in section number (address >> SECTION_SHIFT).
So, that makes it easy to go from a virtual address to a 'struct page'
inside of the mem_map[].
But, given a physical address (or a pfn for that matter), you sometimes
also need to get to a 'struct page'. It is for that reason that we have
the phys_section[] array. Each entry in the phys_section[] points back
to a mem_section[], which then contains the mem_map[].
pfn_to_page(unsigned long pfn)
{
return
&mem_section[phys_section[pfn_to_section(pfn)]].mem_map[section_offset_pfn(pfn)];
}
pfn_to_section(pfn) does a (pfn >> (SECTION_SHIFT - PAGE_SHIFT)), then
uses that section number to index into the phys_section[] array, which
gives an index into the mem_section[] array, from which you can get the
'struct page'.
-- Dave
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>