Professional Documents
Culture Documents
org/node/2450
Home
Author
Feature: High Memory In The Linux Kernel Information
Submitted by Amit Shah on February 21, 2004 - 6:02am
high memory Linux memory memory management PAE RAM Amit Shah
Linux feature article
Offline
As RAM increasingly becomes a commodity, the prices drop and
computer users are able to buy more. 32-bit archictectures face certain Joined: Feb 28 2003
limitations in regards to accessing these growing amounts of RAM. To
better understand the problem and the various solutions, we begin with
an overview of Linux memory management. Understanding how basic
Navigation
memory management works, we are better able to define the problem, Create content
and finally to review the various solutions. Mailing list archives
Recent posts
This article was written by examining the Linux 2.6 kernel source code
for the x86 architecture types.
1 of 20 2/27/2011 9:23 PM
Feature: High Memory In The Linux Kernel | KernelTrap http://kerneltrap.org/node/2450
the upper 1 GB space is reserved for the kernel virtual addresses. This
is true for all processes. © 2001-2009 KernelTrap. |
Powered by Drupal. | Legal
statement.
+----------+ 4 GB
| |
| |
| |
| Kernel |
| | +----------+
| Virtual | | |
| | | |
| Space | | High |
| | | |
| (1 GB) | | Memory |
| | | |
| | | (unused) |
+----------+ 3 GB +----------+ 1 GB
| | | |
| | | |
| | | |
| | | Kernel |
| | | |
| | | Physical |
| | | |
|User-space| | Space |
| | | |
| Virtual | | |
| | | |
| Space | | |
| | | |
| (3 GB) | +----------+ 0 GB
| |
| | Physical
| | Memory
| |
| |
| |
| |
| |
+----------+ 0 GB
Virtual
Memory
The Problem
So, the basic problem here is, the kernel can just address 1 GB of
virtual addresses, which can translate to a maximum of 1 GB of
physical memory. This is because the kernel directly maps all available
kernel virtual space addresses to the available physical memory.
2 of 20 2/27/2011 9:23 PM
Feature: High Memory In The Linux Kernel | KernelTrap http://kerneltrap.org/node/2450
Solutions
1. 2G / 2G, 1G / 3G split
2. HIGHMEM solution for using up to 4 GB of memory
3. HIGHMEM solution for using up to 64 GB of memory
1. 2G / 2G, 1G / 3G split
Before looking at solutions 2 & 3, let's take a look at some more Linux
Memory Management issues.
Zones
In Linux, the memory available from all banks is classified into "nodes".
These nodes indicate how much memory each bank has. This
classification is mainly useful for NUMA architectures, but it's also used
for UMA architectures, where the number of nodes is just 1.
3 of 20 2/27/2011 9:23 PM
Feature: High Memory In The Linux Kernel | KernelTrap http://kerneltrap.org/node/2450
the kernel can access, 128MB is reserved. This means that the kernel
virtual address in this 128 MB is not mapped to physical memory. This
leaves a maximum of 896 MB for ZONE_NORMAL. So, even if one has
1 GB of physical RAM, just 896 MB will be actually available.
Since Linux can't access memory which hasn't been directly mapped
into its address space, to use memory > 1 GB, the physical pages
have to be mapped in the kernel virtual address space first. This means
that the pages in ZONE_HIGHMEM have to be mapped in
ZONE_NORMAL before they can be accessed.
The reserved space which we talked about earlier (in case of x86, 128
MB) has an area in which pages from high memory are mapped into
the kernel address space.
4 of 20 2/27/2011 9:23 PM
Feature: High Memory In The Linux Kernel | KernelTrap http://kerneltrap.org/node/2450
Excellent article
Anonymous on February 21, 2004 - 9:44am
It's great to see stuff like this on Kerneltrap. More please!
reply
5 of 20 2/27/2011 9:23 PM
Feature: High Memory In The Linux Kernel | KernelTrap http://kerneltrap.org/node/2450
critical
Anonymous on February 23, 2004 - 1:16am
I enjoy this type of critical review of the linux kernel and how
it most evolve.
reply
PAE vs AMD64
Anonymous on February 21, 2004 - 10:02am
"This is enabled via the PAE (Physical Address Extension)
extension of the PentiumPro processors. PAE addresses the 4
GB physical memory limitation and is seen as Intel's answer to
AMD 64-bit and AMD x86-64."
How can you claim PAE is an answer to AMD64 if it dates back
to PentiumPro ? AMD64 didn't even exist at that time.
reply
6 of 20 2/27/2011 9:23 PM
Feature: High Memory In The Linux Kernel | KernelTrap http://kerneltrap.org/node/2450
reply
not true
Anonymous on February 22, 2004 - 9:27am
He's right, Pentium Pro's have a PAE register.
reply
7 of 20 2/27/2011 9:23 PM
Feature: High Memory In The Linux Kernel | KernelTrap http://kerneltrap.org/node/2450
8 of 20 2/27/2011 9:23 PM
Feature: High Memory In The Linux Kernel | KernelTrap http://kerneltrap.org/node/2450
9 of 20 2/27/2011 9:23 PM
Feature: High Memory In The Linux Kernel | KernelTrap http://kerneltrap.org/node/2450
10 of 20 2/27/2011 9:23 PM
Feature: High Memory In The Linux Kernel | KernelTrap http://kerneltrap.org/node/2450
11 of 20 2/27/2011 9:23 PM
Feature: High Memory In The Linux Kernel | KernelTrap http://kerneltrap.org/node/2450
your explaination.
I don't understand why the kernel has to map
all available memory
into its its own space. It seems to me that it
should only
have to map the page tables corresponding to
the physical memory into its own space. As
long as it has data structures that track all
pages of physical memory why does it need to
access them. If the physical pages are
mapped into process space, then when the
process makes a system call, the kernel
should have access to copy any memory to
kernel space because it's in the context of the
calling process and can use its page tables.
Also, why have a 3:1 split when you can't map
3 GB of physical memory
anyway. I now you have 3 GB of virtual
address space, but what
good is it if you can't access physical memory.
I guess you could
have 896 MB of physcical memory and 2 GB
of swap, but I don't see the
rational behind this.
Thanks
Kevin
reply
Swap
Anonymous on February 22, 2004 - 1:38am
I've got 2 question :
- Is the swap accounted as available RAM ? For instance, is
2Gb RAM + 4Gb Swap over the 4Gb limit ?
- The HIGHMEM I/O support is not explained (recent in 2.4) :
does the bouncing the article talk about remain true if this option
is set ?
reply
Re: Swap
Anonymous on February 22, 2004 - 12:37pm
1) Swap is not accounted as available RAM for this. There
is no limit on the sum of swap + RAM, only a limit on swap's
size (man mkswap says it is 2Gb). And with 2Gb of RAM
you must use HIGHEM support since it is more than 1 Gb of
RAM.
2) No idea about this, but the Documentation/Configure.help
seems to say you are right. But it seems that drivers must
do some work themselves to use it. Actually, for what I
could check the scsi driver support it: grep through the
kernel for "blk_nohighio". Only drivers/scsi/ contains
12 of 20 2/27/2011 9:23 PM
Feature: High Memory In The Linux Kernel | KernelTrap http://kerneltrap.org/node/2450
13 of 20 2/27/2011 9:23 PM
Feature: High Memory In The Linux Kernel | KernelTrap http://kerneltrap.org/node/2450
This sure seems to imply that the article is correct, and that
there is overhead associated with enabling highmem to get
access to the extra 128 megs... More, that the overhead is
probably not worth the gain. This sentiment is frequently
echo'd on the lkml...
reply
Overhead
Con Kolivas on February 22, 2004 - 5:09pm
The overhead of enabling the extra 128Mb used to
be great in 2.4, especially before the later additions
to the vm by -aa (around 2.4.23), so it was very
true that performance would suffer. It had nothing
to do with what the devices could access; it was
the extra structures put in place to use high mem.
2.6, however, has taken away a lot of that
overhead so it isn't a big performance hit.
reply
HIGHMEM
Anonymous on February 24, 2004 - 4:22am
so from what i read : DONT USE 1GB RAM
even if u have it ?!
ironicaly i have 3 such machines already....
now what ?
One of them condtatnly crashing, now
14 of 20 2/27/2011 9:23 PM
Feature: High Memory In The Linux Kernel | KernelTrap http://kerneltrap.org/node/2450
Clarify recommendation
Con Kolivas on February 24, 2004 -
5:52am
I would recommend not using high mem
support with 1Gb ram and sacrifice 128Mb
unless you are running 2.6. If you are
running 2.6 it is fine to enable high mem
with 1Gb ram.
reply
HIGHMEM
Anonymous on February 27, 2004 -
8:01am
now I'm sure HIGHMEM was the
reason for the crashes..
w/o it my uptime passed 3 days...
not totaly sure yes, will see on
monday if it is still up..
reply
15 of 20 2/27/2011 9:23 PM
Feature: High Memory In The Linux Kernel | KernelTrap http://kerneltrap.org/node/2450
16 of 20 2/27/2011 9:23 PM
Feature: High Memory In The Linux Kernel | KernelTrap http://kerneltrap.org/node/2450
appeal
Anonymous on February 23, 2004 - 11:46am
I would like to appeal against the decision to mark my earlier
message as a flamebait post (see post with the subject "This
article gives the impression..."). I don't understand why it was
considered as such. In the first sentence I state that the
impression this article gives is in fact incorrect (looking at other
posts it appears that I am not the only one who thinks so). In
the second sentence I questioned the author's understanding of
the subject. In particular, I didn't do any of the following:
17 of 20 2/27/2011 9:23 PM
Feature: High Memory In The Linux Kernel | KernelTrap http://kerneltrap.org/node/2450
Re: appeal
neveripe on February 23, 2004 - 12:41pm
You haven't stated motivation for your impression.
reply
Re: appeal
Anonymous on February 23, 2004 - 4:40pm
Ah, I see, I haven't cited the article. Well, to correct my
mistake I would like to provide the following quotations.
I especially like the last one.
"So, the basic problem here is, the kernel can just
address 1 GB of virtual addresses, which can translate
to a maximum of 1 GB of physical memory. This is
because the kernel directly maps all available kernel
virtual space addresses to the available physical
memory."
"To address memory from 1 GB onwards, the kernel
has to map pages from high memory into
ZONE_NORMAL."
"Since Linux can't access memory which hasn't been
directly mapped into its address space, to use memory
> 1 GB, the physical pages have to be mapped in the
kernel virtual address space first. This means that the
pages in ZONE_HIGHMEM have to be mapped in
ZONE_NORMAL before they can be accessed."
reply
Re: appeal
Amit Shah on February 23, 2004 - 9:56pm
So what's your point? I see no contradictions in
these statements and I _know_ for a fact that they
are true.
reply
Re: appeal
Anonymous on February 24, 2004 - 9:30am
Your article gives an idea (or maybe it just me
18 of 20 2/27/2011 9:23 PM
Feature: High Memory In The Linux Kernel | KernelTrap http://kerneltrap.org/node/2450
Re: appeal
Amit Shah on February 24, 2004 -
11:20pm
interpret as 'OS (and thus any code that it
is running) cannot access more than 1GB
of memory'?
19 of 20 2/27/2011 9:23 PM
Feature: High Memory In The Linux Kernel | KernelTrap http://kerneltrap.org/node/2450
1 2 next › last »
Select your preferred way to display the comments and click "Save
settings" to activate your changes.
20 of 20 2/27/2011 9:23 PM