Shrinking the Inactive List

As shrink_inactive_list is responsible only for removing pages from the zone->inactive_list chunk-by-chunk, its implementation is not particularly complicated, as the code flow diagram in Figure 18-16 shows.

Tru_add_drain"| isolate_lru_pagesI

shrink_page_list

Handle direct reclaim

Put back unfreeable pages to LRU lists

Return number of reclaimed pages shrink_ca shrink_ca shrink_page_list

Handle direct reclaim

Figure 18-16: Code flow diagram for shrink_cache.

The first step is to invoke the familiar lru_add_drain function to distribute the current content of the LRU cache to the lists of active and inactive pages in the various zones. This is necessary to cover all inactive pages currently present in the system.

A loop is then repeatedly executed until either the maximum permissible number of pages has been scanned or the required number of pages has been written back. Both numbers are passed to the procedure as a parameter.

Within the loop, the isolate_lru_pages function, as discussed in Section 18.6.5, is invoked to remove a bundle of pages from the back of the list of inactive pages so that the most inactive pages are swapped out by preference. The kernel essentially passes the finished list to shrink_page_list, which initiates writing back the pages on the list. However, things are slightly complicated by lumpy writeback:

Continue reading here: Mmvmscanc

Was this article helpful?

0 0