Understanding the mapping of physical memory to kernel address space
Arun KS
getarunks at gmail.com
Thu Mar 12 14:03:22 EDT 2015
Hello Sunny,
On Thu, Mar 12, 2015 at 10:32 PM, 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?
Yes. Incase of 3:1 mapping, kernel virtual address starts at
0xc0000000. You can also have 2:2 mappings aswell. It is a
configurable option
>
> 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?
If you are using 3:1 user to kernel mapping, your kernel will have 1GB
of virutal addres space.
And if you have 1GB of RAM, whole ram cannot be mapped to kernel
virtual address, because you have to spare some virtual kernel address
space for io memory, vmalloc area etc. So you have to map some of DDR
memory as HIGH_MEM.
>
> 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)?
max_low_pfn is the pfn of the last page mapped as low memory. All the
other pfn belongs to HIGH_MEM. They can be dynamically mapped to
vmalloc virutal address space or directly to user virutal address
space. User space memory is the main consumer of HIGH_MEM.
Thanks,
Arun
>
> 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