Search code examples
linuxmemory-managementlinux-kernellinux-device-driverprocess-management

How Linux manages and keeps track of the physical memory pages?


I am asking about Data structures used in the following:

I am wondering how linux tracks all the physical pages. I am not worried about how it keeps the vm_area_struct. What is the data structure used to store all of them?

And how it looks up a particular physical page when it is given a virtual address?

Radix tree? red-black tree? hash table? what?

Thanks.


Solution

  • The kernel keeps an array of struct page structures, one for each physical page.

    A virtual address is looked up by walking the page table structure, which is a tree (defined by the hardware).