Home > OS >  Physical memory is less than 896 MB of kernel mapping directly
Physical memory is less than 896 MB of kernel mapping directly

Time:10-10

Recent research kernel, but have a few questions don't understand, ask the kernel experts, hope to be able to help me to solve:

1, the kernel mapping is less than 896 MB of physical memory directly, I understand that map the page table entries should be set up, at least the page table entries Field Field (20, that is, page frame physical address maximum 20) have pointed to the corresponding physical memory?

2, the kernel directly mapping the first 896 MB of physical memory, mapping the does not necessarily represent page frame has been allocated to the kernel? The map but may the Present field of page table entries (refer to page 1 said in main memory) or zero? Because if the kernel mapping here before 896 MB page frame has been allocated, so when the host all less than 896 MB of physical memory, the user process, there is no page frame can be allocated?

3, if I point 2 is correct, then the kernel access map page but no distribution box on page, then should be able to produce abnormal missing page? Should be found that the Present is 0, so the result of abnormal page?

CodePudding user response:

Ask and answer!!!!!!!!!!

CodePudding user response:

1. Before the kernel directly mapping the 896 MB of physical memory, with 3 g + X virtual address can access the physical address of X, which is the kernel initialization when the memory manager to establish the mapping, the p in the page table is 1, the page table to ensure a uniform linear mapping, only guarantee any moment kernel can direct access to physical memory (regardless of high-end memory),
2. The memory is the memory manager redistribution, such as creating a mapping of the user process virtual address space, then in fact a physical page can be accessed through multiple virtual addresses, (is the kernel manages memory, it distributes memory process, allocate memory to it that there is no others)
3. The final advice to understand the old version of the process of establishing the kernel memory manager bootmem and buddy allocator code can refer to the 2.4.0 kernel, cooperate with the kernel scenario analysis that book,

CodePudding user response:

There are many kinds of types, in Linux address bus address and logical address, virtual address, etc., the mapping relationship is very complex,
In my memory, less than 896 million cases, the kernel is to build form all memory, and the kernel virtual address and physical address one-to-one correspondence, the virtual address is unique in the entire operating system, no matter in which process to access the virtual address is finally access to the same physical address, and access is the only way into the kernel,
And you malloc in user space out of the virtual address to kernel mode is completely is not the same, the user's virtual address space, only when you need to use will be generated, and this also apply to the kernel space to a virtual address, i.e. user mode has not its own memory pool, all memory is through similar to the malloc function, such as for BRK system calls into the kernel configuration application, and update the process's virtual address table, took out a piece of free memory in the pool to the kernel process, and give it a virtual address to user mode, that is to say at this point the physical memory has at least a kernel virtual address and a virtual address to user mode, this part can be reference to the use of the mmap, mmap is to use the principle to realize the fast data interaction between kernel and user mode,
  • Related