2013年8月26日 星期一

Memory zone

Reference : Understaning the Linux Kernel Chap.8
Ideal computer architecture上,任意page frame都是可以被access的
但實際上的電腦架構在硬體上會有些限制住page frame被使用
Linux kernel must deal with two hardware constraints of the 80 × 86 architecture:
• The Direct Memory Access (DMA) processors for old ISA buses have a strong limitation: they are able to address only the first 16 MB of RAM.
• In modern 32-bit computers with lots of RAM, the CPU cannot directly access all physical memory because the linear address space is too small. (64-bit machine have no this problem)

所以Linux2.6就把每個memory node切成三個zone:
ZONE_DMA - Contains page frames of memory below 16 MB
ZONE_NORMAL - Contains page frames of memory at and above 16 MB and below 896 MB
ZONE_HIGHMEM - Contains page frames of memory at and above 896 MB
而ZONE_DMA就是用來當作device的DMA
ZONE_DMA跟ZONE_NORMAL都可以透過linear mapping而被kernel access
但ZONE_HIGHMEM不行

舉個例來說kernel invoke __get_free_pages(GFP_HIGHMEM,0) to allocate a page frame in high memory
allocator若是指定一high memory的page frame的話,__get_free_pages() cannot return its linear address because it doesn’t

The allocation of high-memory page frames is done only through the alloc_pages()
Therefore, part of the last 128 MB of the kernel linear address space is dedicated to mapping high-memory page frames

0 意見:

張貼留言