全部博文(3)
分类: LINUX
2015-07-31 19:43:49
HIGHMEM DISAPPEAR ON 64-bit ARCHITECTURE
Daniel.Ni
What is High Memory?
====================
In short, High memory is memory address which do not have logical address.
+--------------+ +--------+
Logical => | Segmentation | Linear => | Paging | => Physical
Address | Unit | Address | Unit | Address
+--------------+ +--------+
In 80x86 platform of Linux, segmentation are used in a very limited way.
As a result, logical addresses coinside with linear addresses. 4GB linear
addresses are divided into two parts.
* 0x00000000 - 0xbfffffff are user space
* 0xc0000000 - 0xffffffff are kernel space
Why linux designers do this?
* It is for privilige use. Different logical address may lead to
different CPL through segmentation, which can provide protection.
* It is covenient for MMU mapping. We can use the same Page Table
leaving the kernel paging tables unchanged.
When linux running, running space switch between user and kernel happens
frequently. For instance, linux system call. If we use the same linear
address between user and kernel, it means that, we must let MMU do dynamic
address mapping, modifying the page tables for every space switch happens.
What's wrong with modifying the Page Tables?
Frequent Page Table modifications lead to higher average memory access times,
because they make the CPU flush the contents of the translation lookaside
buffers. Causing low CPU efficiency.
So there are 1GB left for kernel to use. When physical memory is less than
1GB, it could be easily directly mapped by kernel. But when physical memory
is more than 1GB, for example, 1.5GB, the left 512MB cannot be directly used
by kernel (for kernel, these physical address do not have logical address).
So, Linux designer choose another way to manage memory. The physical memory
that are less than 896MB are directly mapped. another 128MB are dynamically
allocated by kernel, using 128MB linear address could mapping the whole left
896MB ~ 4GB. The memory of 896MB-1GB are called High memory.
On the contrast, Low memory means less than 896MB. Low memory are used for
kernel space, while High memory can be accessed both user and kernel space.
On i386 systems, the boundary between low and high memory is usually set a
just under 1GB, that boundary can be changed at kernel configuration time.
It just splits the 32-bit address space between kernel and user space.
High Memory Disappear on 64-bit Architecture
=============================================
Linear memory address are divided as proportion of 3:1. In 64-bit machine,
theoretically, we could access 2^64 Bytes size of linear address space,
Actually, linear address space doesn't need so large. If memory address has
48 lines, We can access 2^48 Bytes of linear address, that would be large as
64K * 4GB. 16K * 4GB can be used for kernel space, which is large enough for
the whole physical memory directly mapped.