Spyder
Spyder

Reputation: 974

In linux kernel what is difference between page address, virtual address and physical address

In linux kernel what is difference between page address, virtual address and physical address? Also if I have struct page address how can I find its virtual address?

Could someone please explain it clearly with respect to Linux kernel version 3.10.

Thanks in advance for your answers.

Upvotes: 2

Views: 1066

Answers (1)

McGlothlin
McGlothlin

Reputation: 2099

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

Upvotes: 4

Related Questions