Linux Kernel zones have the following types: zone_dma, zone_normal, and zone_highmem.
Each zone type is applicable to different use types:
Zone_dma is a low-end physical memory range suitable for ISA Device requests. The zone_dma physical page box maps to the Kernel linear address space.
Zone_normal is directly mapped to the Kernel linear address space. Common kernel operations occur in zone_normal.
Zone_highmem is the remaining available memory, and the kernel does not directly map this part of memory.
Because the kernel address space is limited, there is no direct address ing on highmem, so the kernel cannot directly operate on the page boxes in the highmem space. However, the kernel can map highmem to the kernel address space in the following ways:
1. Use pkmap for temporary ing
2. fixmap fixed address ing
3. vmalloc allocating non-contiguous memory areas
In addition, the process can map highmem to the user address space of the process.
Use pkmap for temporary ing
The kernel retains a 2 m/4 m linear address space before the fixmap linear address space, and uses pkmap to temporarily map the high-end memory to this space. pkmap is a small address space: only 2 m or 4 m.
Use fixmap ing for fixed address ing
Fixmaps is a virtual address space reserved by the kernel and can be mapped to any physical memory. Therefore, we can think that fixmap will also use highmem, And the fixmaps address space is very limited, the typical address range is 0xffc00000 ~ 0xfffff000.
Kernel allocation of non-contiguous memory areas
Vmalloc will first use highmem zone to allocate the page box. It will be allocated from normal zone only if the allocation from highmem zone fails.
User space ing
Although the kernel address space is limited, the user address space of each process can reach 3 GB, And the highmem page box can be mapped to the user's linear address space without restrictions. When a page error occurs when you access the user address space address, the kernel page Allocator will first distribute pages from the highmem zone. Only when the highmem zone does not have enough idle pages, select normal or DMA zone for allocation.
Therefore, the main user of highmem memory is the page ing of the application process. The kernel uses the pkmap fixmap mode and the highmem memory is used at most 2 MB/4 MB + 3.xmb. due to the existence of highmem, in this way, the highmem zone memory is preferentially used for operations such as page Exception Handling, file ing, and heap allocation of application address space, which reduces the allocation pressure of the normal zone and avoids the fragmentation of the normal zone to some extent. We can even disable high_mem allocation of user space addresses from using normal zone and DMA zone, so that normal DMA is only used for memory allocation of kernel address space, minimizing fragmentation and avoiding memory allocation failure. I think this is the significance of the existence of highmem.