As we all know, the kernel divides a linear address (also called a virtual address in most cases) into three parts: physical memory ing area, vmalloc ing area, and fixed ing address area. The first two types are discussed here.
The so-called physical memory ing zone refers to the one-to-one ing zone with the physical memory. For example, if the system has a physical memory of 512 MB, the linear address from 0xc0000000 to 0xc00000000 + 512m belongs to the physical memory ing zone. This linear address has a one-to-one correspondence with the physical memory during system initialization. The one-to-one ing here refers to the difference between the physical address and the linear address 0 x c0000000. The function _ Pa () is to directly subtract the linear address 0 x c0000000 to obtain the physical address. Therefore, the application scope of this function is limited to the physical address ing area. _ Pa () is incorrect for the other two address zones. The reason is simple. The physical address is not that big.
The vmalloc ing area is characterized by a continuous linear address, and its physical address is not necessarily consecutive. This ing feature is the same as that of user address space ing. In the physical memory ing area mentioned above, the linear and physical addresses are obviously continuous. Of course, the final ing must be the ing between linear and physical addresses. Therefore, this linear address must be mapped to the physical memory. This will conflict with the physical memory ing zone: because all physical memory ing areas already have a linear address. However, we know that physical memory is not used all the time. That is to say, although it has been mapped, no one has used it. Then, we can map to unused memory in the vmalloc ing area and lock it. In this way, the memory will not be allocated for other purposes. Therefore, although the ing conflicts, no two linear addresses are used at the same time.
Because the linear and physical addresses in the vmalloc ing area do not have a fixed ing relationship, we can only find the corresponding physical page box by searching the page table. It is worth mentioning that the vitual field of the physical page frame (struct Page Structure) still stores the linear address of the physical memory ing area, that is to say, if the _ page_to_vir () operation is performed on the physical address, the obtained linear address is not the linear address in the vmalloc ing area.
Www.linuxhao.com, a good school for Linux, provides video tutorials for Linux, training courses for LinuxTechnical materialsDownload and share resources for free.