Understanding the mapping of physical memory to kernel address space
Arshad Hussain
arshad.super at gmail.com
Thu Mar 12 14:03:57 EDT 2015
On 12-Mar-2015, at 10:02 am, Sunny Shah <shahsunny715 at gmail.com> wrote:
> Hello,
>
> This is my first mail on this list, so please let me know if I'm erring.
>
> I'm reading Bovet and Cesati's "Understanding the Linux Kernel", specifically the chapter "Memory Addressing", sub-section "Kernel Page Tables". Here they describe how Linux initializes its page tables for various RAM sizes and how much of the physical address space is mapped onto the kernel virtual address space.
>
> I have several questions from my reading:
>
> • My understanding is that the 32 bit virtual address space of a process is split into 2 parts - the first 3 GiB for the user space and the remaining 1GiB for the kernel (with the same kernel mapping being used for all processes. However, although the kernel is mapped into the higher portion of the address space, it resides in the lower 1 GiB of RAM. Is this correct?
Not the lowest 1GB of RAM. This portion is non-contiguous, (video memory , ROM etc…).
However, the kernel resides from 0x01000000 (16MB) which is physical address and is mapped to 0xC0000000 (virtual address).
>
> • There is a frequent mention of "mapping RAM to the kernel address space". Is the whole RAM mapped to the kernel space? What would happen in the case of a machine having only 1 GiB of RAM?
Paging.
Think of this in reverse order. Instead of looking as whole RAM is mapped, think of the whole process is mapped (which ofcourse is virtual).
Now, everytime there is a need to read/write a location that virtual page must be backed by a page in real memory (RAM).
Paging allows partial text, bss and data to be executed using swapping to bring in/out pages as and when required.
This also allows other process to run in small amount of RAM.
>
> • Related to the above, what exactly is max_low_pfn? It is mentioned it is the "Page frame number of the last page frame directly mapped by the kernel (low memory)". What would it's value be for a machine with 1 GiB RAM? For a machine with 4 GiB RAM, would it be the number of the frame covering the last portion of kernel space (896 MiB)?
Not to _sure_ on this. min and max pfn are closly tied to zones. for both it will be 896MB. (Please read High memory)
Thanks
>
> Sorry if my questions are a bit vague. I'm still new to this and having difficulty relating everything.
>
>
> Thanks,
> Sunny
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
More information about the Kernelnewbies
mailing list