Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why do we need zone_highmem on x86?

In linux kernel, mem_map is the array which holds all "struct page" descriptors. Those pages includes the 128MiB memory in lowmem for dynamically mapping highmem.

Since the lowmem size is 1GiB, so the mem_map array has only 1GiB/4KiB=256KiB entries. If each entry size is 32 byte, then the mem_map memory size = 8MiB. But if we could use mem_map to map all 4GiB physical memory(if we have so much physical memory available on x86-32), then the mem_map array would occupy 32MiB, that is not a lot of kernel memory(or am i wrong?).

So my question is: why do we need to use that 128MiB in low for indirect highmem mapping in the first place? Or put another way, why not to map all those max 4GiB physical memory(if available) in the kernel space directly?

Note: if my understanding of the kernel source above is wrong, please correct. Thanks!

like image 650
jscoot Avatar asked Feb 23 '09 07:02

jscoot


1 Answers

Look Here: http://www.xml.com/ldd/chapter/book/ch13.html

Kernel low memory is the 'real' memory map, addressed with 32-bit pointers on x86.

Kernel high memory is the 'virtual' memory map, addressed with virtual structures on x86.

You don't want to map it all into the kernel address space, because you can't always address all of it, and you need most of your memory for virtual memory segments (virtual, page-mapped process space.)

At least, that's how I read it. Wow, that's a complicated question you asked.

To throw more confusion, chapter 13 talks about some PCI devices not being able to address the 32-bit space, which was the genesis of my previous comment:

On x86, some kernel memory usage is limited to the first Gigabyte of memory bacause of DMA addressing concerns. I'm not 100% familiar with the topic, but there's a comapatibility mode for DMA on the PCI bus. That may be what you are looking at.

like image 80
Chris Avatar answered Nov 15 '22 06:11

Chris