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

Related Posts:

  • Describing Physical MemoryReference: http://www.chudov.com/tmp/LinuxVM/html/understand/node16.html NUMA(non-uniform memory access)架構下,memory被分成很多的bank(又稱為node),而每個bank被CPU access的cost不同 Linux用struct pg_data_t來代表bank(or node) 而PC是一UMA的架構,所以只有一個p… Read More
  • Memory zoneReference : 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 D… Read More
  • Booting ARM system from bootloader to linux kernel有空來讀一下 會以u-boot code當作bootloader base 開到start_kernel之前的組語部分可以參考 http://gicl.cs.drexel.edu/people/sevy/linux/ARM_Linux_boot_sequence.html… Read More
  • Allocating and Freeing Page TablesReference : http://www.chudov.com/tmp/LinuxVM/html/understand/node26.html 因為page table的allocation跟free有很大的cost,而且又是很常要執行的操作(process create&delete) 所以Linux kernel使用quicklists來cache住用來當page table的page quicklist包含pgd_quick… Read More
  • Kernel Space MemoryReference : http://www.chudov.com/tmp/LinuxVM/html/understand/node28.html Kernel的virtual memory適用linear mapping,physical address 0對應到kernel virtual memory的PAGE_OFFSET(通常是0xC000_0000) 也就是說kernel virtual address - PAGE_OFFSET就… Read More

0 意見:

張貼留言