next up previous contents index
Next: 10.3 Shrinking all caches Up: 10. Page Frame Reclamation Previous: 10.1 Page Swap Daemon   Contents   Index

10.2 Page Cache

The page cache consists of two lists defined in mm/page_alloc.c called active_list and inactive_list which broadly speaking store the ``hot'' and ``cold'' pages respectively. The lists are protected by the pagemap_lru_lock. The objective is for the active_list to contain the working set[#!denning70!#] and the inactive_list contain pages that can be reclaimed.



\includegraphics[width=17cm]{graphs/lrulist.ps}
[1]
Figure: Page Cache LRU List
[2]


The page cache is generally said to use a Least Recently Used (LRU) based replacement algorithm but that is not strictly speaking true as the lists are not strictly maintained in LRU order. They instead resemble a simplified LRU 2Q[#!johnson94low!#] where two lists called Am and A1 are maintained. Pages when first allocated are placed on a FIFO queue called A1. If they are referenced while on that queue, they are placed in a normal LRU managed list called Am. This is roughly analogous to using lru_cache_add() to place pages on a queue called inactive_list (A1) and using mark_page_accessed() to get moved to the active_list (Am). The algorithm describes how the size of the two lists have to be tuned but Linux takes a simpler approach by using refill_inactive() to move pages from the bottom of active_list to inactive_list to keep active_list about two thirds the size of the total page cache.

The lists described for 2Q presumes Am is an LRU list but the list in Linux closer resembles a Clock algorithm[#!carr84!#] where the handspread is the size of the active list. When pages reach the bottom of the list, the referenced flag is checked, if it is set, it is moved back to the top of the list and the next page checked. If it is cleared, it is moved to the inactive_list.


Table 11.1: Page Cache API
\begin{table}\begin{center}
\begin{tabularx}{13.5cm}{\vert X\vert}
\hline
a...
...hould be used
instead \\ \\\hline
\end{tabularx}
\end{center} \end{table}



next up previous contents index
Next: 10.3 Shrinking all caches Up: 10. Page Frame Reclamation Previous: 10.1 Page Swap Daemon   Contents   Index
Mel 2003-01-14