a) __pa(kaddr) : Translates kernel virtual address to physical address, which is just arithmetic operation subtracting PAGE_OFFSET from kaddr.
b) #define virt_to_page(kaddr) (mem_map + (__pa(kaddr) >> PAGE_SHIFT)) above macro is giving you struct page for a corresponding virtual address. c) linear address to physical address translation is done by x86 processor (32 but without PAE) by doing traversal pgd->pte->page_phys_addr. OS sets up this entries and processor uses it. Yes, above macro is not for ZONE_HIGHMEM. Because ZONE_HIGHMEM is not directly mapped by kernel. Shailesh Jain On Fri, Oct 23, 2009 at 2:01 PM, Shameem Ahamed <[email protected]>wrote: > Hi Friends, > > Please help me to figure out some basic concepts in MM. > > From the books, i learned that VMA to PA translation consists of traversing > the full page directory, which consists of Global Directory, Middle > Directory and Page Table. > > I have also read that, VMA to PA translation is done using a macro > virt_to_page defined as given below. > > #define virt_to_page(kaddr) (mem_map + (__pa(kaddr) >> PAGE_SHIFT)) > > > If > there is a macro, why we need code for traversing all the page > directories ?. This macro is a simple math, which points to an index > in global mem_map array, which contains all the pages in the system. > > > So my doubts are, > Is the macro only for ZONE_NORMAL (upto 896M, which is directly mapped by > kernel) memory pages ?. > Is mem_map array contains pages upto ZONE_NORMAL ? > Is page traversing happens only for HIGH_MEM ?. > > Regards, > Shameem > > > > > > -- > To unsubscribe from this list: send an email with > "unsubscribe kernelnewbies" to [email protected] > Please read the FAQ at http://kernelnewbies.org/FAQ > >
