Each physical page is described by a Ppage structure. This structure tracks the following key information about the page:
Pages are reference counted if they are allocated to a user-level process. The kernel can hold references to such pages, but the only way a user-level process can hold a reference is by mapping the page. When the last mapping to a page is removed the page is considered free-able.
Process call sys_insert to modify the x86 page table associated with the environment. To unmap a page, insert a pte without the PG_P (present bit) set. To map a page, insert a pte that points to a physical page that is not allocated (to allocate it) or to a physical page that is allocated and which the caller presents an appropriate capability for.