> 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.

That's a noble question. But if you think about it, the processor's
MMU is what walks these directories to find the page table entry
(containing the physical address) corresponding to a particular
virtual memory address. The kernel sets these tables up for the
processor. Also the mem_map array contains "page descriptors". This is
the structure that describes a particular page frame in physical
memory. (http://lxr.linux.no/#linux+v2.6.31/include/linux/mm_types.h#L40)
The macro you're talking about doesn't translate virtual to physical
addresses, it just fetches the page descriptor of the physical page
which the virtual memory address translates to, from the mem_map
array.

> 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 ?

No, all physical memory is described.

> Is page traversing happens only for HIGH_MEM ?.

No, page transversing done by the CPU happens for all virtual
addresses. Further NORMAL HIGH AND LOW MEM are physical memory areas,
not virtual.
About low / high mem, what I understand is for 32 bit x86
architectures, the kernel couldn't directly access physical memory
(using virtual addresses)  above 896MB. Only 0 - 896MB was directly
mapped - so the kernel image had to be loaded in this directly mapped
memory and couldn't be loaded in physical memory above 896MB. The only
way the kernel could access physical memory above 896MB was by
indirectly setting up temporary mappings and cycling these mappings
between requests. In 64 bit architectures, the kernel doesn't use
HIGH_MEM at all.

Hope the above makes sense. Let me know if I went wrong anywhere..

-Joel

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ

Reply via email to