在linux内核中,页面地址,虚拟地址和物理地址有什么区别

时间:2015-10-29 15:27:27

标签: linux linux-kernel

在linux内核中,页面地址,虚拟地址和物理地址有什么区别?如果我有结构页面地址,我怎么能找到它的虚拟地址?

有人可以就Linux内核版本3.10清楚地解释一下。

提前感谢您的回答。

1 个答案:

答案 0 :(得分:4)

A physical address is the address in RAM. Once you reach the limit of physical memory available, the kernel has to allocate somewhere, and that place is the virtual address space. Virtual memory is mapped such that you have much more available than you have physical memory, and this is done by breaking virtual memory into chunks called pages.

Each virtual address is mapped to a location in physical memory, where there is a 1 to many relationship between physical to virtual addresses i.e., there are many virtual addresses that map to the same physical location. This mapping is done by address translation in the page table.

A page is the smallest unit of virtual memory. The page size varies depending on architecture and implementation, but on x86 for Linux it is 4 KiB. When working with virtual memory, you must read the entire page, not just a chunk. When you say "page address", you may be referring to the index within a page where a specific virtual address can be found.

While fact-checking my answer, I came across some good pages that might help you understand virtual memory a little better. The first 2 are Wikipedia and fairly general, and the last two are Linux specific:

Virtual Memory

Paging

Memory Management for Linux page 1 and page 2