Hi, I read a few articles on linux virtual memory management such as this one : http://lwn.net/Articles/75174/ which say that earlier linux kernel could only use memory slightly below 1 GB. They have given the reason for it but I am unable to understand.They further describe the use of High memory and low memory. Could anybody please explain the reason for kernel not being able to use the 1 GB completely? Also please provide references for high memory and low memory. Thanks Vaibhav Jain
Hi Vaibhav, On Mon, Jul 25, 2011 at 3:17 PM, Vaibhav Jain <vjoss197@gmail.com> wrote:
Hi,
I read a few articles on linux virtual memory management such as this one : http://lwn.net/Articles/75174/
which say that earlier linux kernel could only use memory slightly below 1 GB. They have given the reason for it but I am unable to understand.They further describe the use of High memory and low memory. Could anybody please explain the reason for kernel not being able to use the 1 GB completely? Also please provide references for high memory and low memory.
My numbers/comments are for the ARM processor, the x86 may be slightly different. The typical configuration for the kernel has addresses from 0x00000000 through 0xC0000000 given to user space (it's actually a small amount less than 3 GB since modules are loaded in the space just before 0xC0000000). That leaves 0xC0000000 to 0xFFFFFFFF for kernel virtual memory (or 1 Gb). Now devices need some I/O space, which takes away from the 1Gb. I think what you're calling low memory is kernel logical memory. See http://lwn.net/images/pdf/LDD3/ch15.pdf on page 414 (not the 414th page of the PDF, but the page with 414 printed on the bottom). High memory is memory which is not directly accessible by the kernel. You need to use kmap/kunmap to map the memory into the kernel virtual memory space. Low memory is always accessible by the kernel. So user-mode programs get allocated from high-memory (if high memory exists) since the kernel doesn't typically need to access the user-space memory. It is possible to set some CONFIG options and have the 3Gb/1Gb split changed to 2Gb/2Gb or 1Gb/3Gb, but 3Gb/1Gb is the normal default. -- Dave Hylands Shuswap, BC, Canada http://www.davehylands.com
Hi Dave, Santhosh, Thanks for the reply! I was talking about the following paragraph from the reference you provided : The kernel (on the x86 architecture, in the default configuration) splits the 4-GB virtual address space between user-space and the kernel; the same set of mappings is used in both contexts. A typical split dedicates 3 GB to user space, and 1 GB for kernel space.* The kernel’s code and data structures must fit into that space, but the biggest consumer of kernel address space is virtual mappings for physical memory. The kernel cannot directly manipulate memory that is not mapped into the kernel’s address space. The kernel, in other words, needs its own virtual address for any memory it must touch directly. *Thus, for many years, the maximum amount of physical memory that could be handled by the kernel was the amount that could be mapped into the kernel’s portion of the virtual address space, minus the space needed for the kernel code itself. As a result, x86-based Linux systems could work with a maximum of a little under 1 GB of physical memory.* I am still not clear about the sentences in bold. Why is the space needed for kernel code subtracted from the amount that could be mapped into kernel's portion of virtual address space ? Also , what difference does the fact - "biggest consumer of kernel address space is virtual mappings for physical memory" make in the amount of memory that can be handled by the kernel. I am little confused. Thanks Vaibhav Jain On Mon, Jul 25, 2011 at 5:51 PM, Dave Hylands <dhylands@gmail.com> wrote:
Hi Vaibhav,
On Mon, Jul 25, 2011 at 3:17 PM, Vaibhav Jain <vjoss197@gmail.com> wrote:
Hi,
I read a few articles on linux virtual memory management such as this one : http://lwn.net/Articles/75174/
which say that earlier linux kernel could only use memory slightly below 1 GB. They have given the reason for it but I am unable to understand.They further describe the use of High memory and low memory. Could anybody please explain the reason for kernel not being able to use the 1 GB completely? Also please provide references for high memory and low memory.
My numbers/comments are for the ARM processor, the x86 may be slightly different.
The typical configuration for the kernel has addresses from 0x00000000 through 0xC0000000 given to user space (it's actually a small amount less than 3 GB since modules are loaded in the space just before 0xC0000000).
That leaves 0xC0000000 to 0xFFFFFFFF for kernel virtual memory (or 1 Gb). Now devices need some I/O space, which takes away from the 1Gb.
I think what you're calling low memory is kernel logical memory. See http://lwn.net/images/pdf/LDD3/ch15.pdf on page 414 (not the 414th page of the PDF, but the page with 414 printed on the bottom).
High memory is memory which is not directly accessible by the kernel. You need to use kmap/kunmap to map the memory into the kernel virtual memory space. Low memory is always accessible by the kernel.
So user-mode programs get allocated from high-memory (if high memory exists) since the kernel doesn't typically need to access the user-space memory.
It is possible to set some CONFIG options and have the 3Gb/1Gb split changed to 2Gb/2Gb or 1Gb/3Gb, but 3Gb/1Gb is the normal default.
-- Dave Hylands Shuswap, BC, Canada http://www.davehylands.com
Hi Vaibhav, On Mon, Jul 25, 2011 at 9:40 PM, Vaibhav Jain <vjoss197@gmail.com> wrote:
Hi Dave, Santhosh,
Thanks for the reply! I was talking about the following paragraph from the reference you provided :
The kernel (on the x86 architecture, in the default configuration) splits the 4-GB virtual address space between user-space and the kernel; the same set of mappings is used in both contexts. A typical split dedicates 3 GB to user space, and 1 GB for kernel space.* The kernel’s code and data structures must fit into that space, but the biggest consumer of kernel address space is virtual mappings for physical memory. The kernel cannot directly manipulate memory that is not mapped into the kernel’s address space. The kernel, in other words, needs its own virtual address for any memory it must touch directly. Thus, for many years, the maximum amount of physical memory that could be handled by the kernel was the amount that could be mapped into the kernel’s portion of the virtual address space, minus the space needed for the kernel code itself. As a result, x86-based Linux systems could work with a maximum of a little under 1 GB of physical memory.
I am still not clear about the sentences in bold. Why is the space needed for kernel code subtracted from the amount that could be mapped into kernel's portion of virtual address space ?
Well the kernel code needs to run from the kernel virtual space.
Also , what difference does the fact - "biggest consumer of kernel address space is virtual mappings for physical memory" make in the amount of memory that can be handled by the kernel.
In order to access memory you need to have MMU tables. These MMU tables are what maps the virrtual to physical memory. MMU entries are needed for every single page. I don't quite think that they take up a huge amount of memory. There is also a page structure for every page of physical memory. -- Dave Hylands Shuswap, BC, Canada http://www.davehylands.com
hi, On Tue, Jul 26, 2011 at 3:47 AM, Vaibhav Jain <vjoss197@gmail.com> wrote:
Hi,
I read a few articles on linux virtual memory management such as this one : http://lwn.net/Articles/75174/
which say that earlier linux kernel could only use memory slightly below 1 GB. They have In Linux to separate the user space and kernel space,total linear address range is divided into two parts 1GB for kernel space and 3GB for user space.This not fixed you can configure it to 2GB and 2GB also. given the reason for it but I am unable to understand.They further describe the use of High memory and low memory. Could anybody please explain the reason for kernel not being able to use the 1 GB completely? The highest 128 MB of linear addresses are left available for several kinds of mappings.So the kernel address space left for mapping the RAM 1GB-128MB=896MB. During initialization phase liinux maps RAM window of 896MB into the kernel linear address space of 896 MB(its kind of one to one mapping for which page table entries are fixed) .The other 128 MB of linear addresses always left available because the kernel uses them to implement non contiguous memory allocation and fix-mapped linear address(for this range page table changes accordingly map and unmap ). Also please provide references for high memory and low memory. please refer to the memory management chapter of understanding linux kernel.
Thanks Vaibhav Jain
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
participants (3)
-
Dave Hylands -
santhosh kumars -
Vaibhav Jain