Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 18: Page Reclaim and Swapping


tomark_page_accessedhave thus been more frequent than the calls topage_referenced,
which implies that the page is often accessed. If the page is currently on the inactive list,
it is moved to the active list. Additionally, thePG_activebit is set, andPG_referencedis
removed.


  1. A downward promotion is also possible. If the page is on the active list and receives
    much attention, thenPG_referencedis usually set. Once the page starts to experience
    less activity, thentwocalls ofpage_referencedare required without intervention of
    mark_page_accessedbefore it is put on the inactive list.


PageActive = 0 (inactive_list)

3

3

1 mark_page_accessed
2 page_referenced
3 shrink_active_list
4 activate_page

Move to
active list

Ref 0 Ref 1
Move to
inactive list

1

4

1

(^22)
PageActive = 1 (active_list)
Ref 0 Ref 1
via 1
(^21)
2
SetPageActive
ClearPageActive
Iru_cache_add Iru_cache_add_active
Figure 18-13: Overview of possible statetransitions of a page with respect toPG_activeand
PG_referenced, and the corresponding placement of the page on the active and inactive lists.
If a page is steadily accessed, then the calls ofmark_page_accessedandpage_referencedwill essentially
average out, so the page remains on its current list.
A page that is not often accessed (and thus inactive) hasnoneof the bitsPG_activeandPG_referenced
set. This means thattwosubsequent activity markings withmark_page_accessed(and without the inter-
ference ofpage_referencedin between) are required to move it from the inactive to the active list. The
same holds vice versa: A highly active page hasbothPG_activeandPG_referencedset.
All in all, the solution ensures that pages do not bounce between the active and inactive lists too fast,
which would clearly be undesirable for a reliable estimation of the page’s activity level. The method is
a variation of the ‘‘second chance’’ approach discussed at the beginning of this chapter: Highly active
pages get a second chance before they are down-promoted to an inactive page, and highly inactive pages
require a second proof before they become active pages. This is combined with a ‘‘least recently used’’
method (or at least an approximation, because no exact usage count is available for the pages) to realize
page reclaim policy.
Note that while Figure 18-13 illustrates the most important state and list transitions, some more are still
possible. This is caused, on the one hand, by code not covered in this book (e.g., the page migration

Free download pdf