Evicting Anonymous pages.

sk.syed2 sk.syed2 at gmail.com
Fri Sep 30 02:43:09 EDT 2011


>  I am trying to understand the kernel page frame reclaiming
> mechanism, but one thing's bothering me:
> How does the kernel 'know' which anonymous pages to evict? In the LRU
> scheme,  'referenced/used' information for each page is required
> (AFAIK). But anonymous pages can be used by user processes 'at any
> time' without the kernel knowing about it.

a. Every anonymous page starts out referenced.
b. The process address space is described by the mm_struct, which has
different regions defined by vm_area_struct(vma).
c. A region may represent the process heap for use with malloc(), a
memory mapped file such as a shared library
or a block of anonymous memory allocated with mmap().
d. Every physical page(atleast those directly mapped into kernel
linear address space) have a struct page associated with it.
e. Now struct page has a struct address_space *mapping  in it. In
mapping, if low bit clear, points to inode address_space else if page
mapped as anonymous low bit is set.
f. Lets say low bit is set, then this mapping points to a anon_vma
struct. This anon_vma is linked list of all vma's that have reference
to that page. If the kernel needs to unmap a anonymous page, it must
follow this linked list and examine every VMA it finds. Once the page
is unmapped from every page table found from each
vma(vma-->mm_struct-->pgd), it can be freed.

-syed



More information about the Kernelnewbies mailing list