Preface: Linux
When I read the source code for the first time, I was worried about the role of high-end memory. When I read it for the second time, I CONFIG_HIGHMEM
turned off the option by default and read it again. I also read many articles on the Internet. The definition of high-end memory is nothing more than what it is called 3G+896MB~4G
. There is no easy-to-understand explanation.
The description of the huge Linux
source code, whether in various video explanations or various books, is simply divided into various modules, and there is little or no information on how the various modules are connected to each other. This is difficult, extremely difficult. You have to understand it yourself and practice it to get your own so-called understanding.
Modular understanding of high-end memory
By default, 4G+
this block is understood as high-end memory
Why is 4G+ high-end memory, VA or PA?
VA
, here 4G+
refers to the virtual address
We know that in IA-32
the architecture, the virtual address space is 1:3
divided according to the kernel, 1G
that is, 3G~4G
(note that the kernel does not care 0~3G
about the process address space here), 32
and the address line. When CPU
analyzing instructions, the virtual address space can always only be divided according to 4G
the previous address, while the kernel occupies the middle and upper1G
Assuming that the 1G
virtual memory of the kernel directly maps physical memory (regardless of the process address space), then the maximum physical address range mapped at this time should be. What 0~1G
if the physical memory is larger than this 1G
? (The maximum virtual address space can only be 4G
, no more can be added)
Then the concept of high-end memory comes on stage. All physical memory higher than 1G
the physical memory is divided into high-end memory, but how to use it specifically?
It can be seen from the source code that during the kernel initialization process, a partner system ( buddy system
) and a memory bitmap and a memory page map ( struct page
) are initialized. They manage the allocation of all physical memory, including high-end memory.
The three mapping methods of high-end memory will not be discussed here. When accessing 3G+896MB~4G
a pair of virtual addresses, temporary mapping or page table technology is used to obtain the physical page from the partner system and establish mapping.
To sum it up: the virtual address space remains unchanged and the physical memory is variable.
Starlight does not care about those who are on the road, and time pays off to those who are willing to do so. Come on, everyone