Mmvmscanc

struct scan_control {

/* Incremented by the number of unsigned long nr_scanned;

gfp_t gfp_mask;

int may_writepage;

/* Can pages be swapped as part int may_swap;

int swappiness;

int all_unreclaimable;

int order;

inactive pages that were scanned */

The meanings of the elements are closely reflected in their variable names:

□ nr_scanned reports to the caller how many inactive pages have been scanned and is used to communicate between the various kernel functions involved in page reclaim.

□ gfp_mask specifies allocation flags that are valid for the context in which the reclaim function is invoked. This is important because it is sometimes necessary to allocate fresh memory during page reclaim. If the context from which reclaim is initiated is not allowed to sleep, this constraint must, of course, be forwarded to all functions called; this is precisely what gfp_mask is designed to do.

□ may_writepage selects whether the kernel is allowed to write out pages to the backing store. Disabling this opportunity is required sometimes when the kernel runs in laptop mode, as discussed in Chapter 17.13.

□ may_swap decides if swapping is allowed as part of the page reclaim endeavors. Swapping is only forbidden in two cases: if page reclaim runs on behalf of the software suspend mechanism, and if a NUMA zone explicitly disables swapping. These possibilities are not considered any further in this book.

□ swap_cluster_max is not actually related to swapping, but gives a threshold for the number of pages per LRU list that are at least scanned in one page reclaim step. Usually, this is set to swap_cluster_max, defined to 32 per default.

□ swappiness controls how aggressively the kernel tries to swap out pages; the value can range between 0 and 100. Per default, vm_swappiness is used. The standard setting is 60, but this can be tuned via /proc/sys/vm/swappiness. See the discussion in Section 18.6.6 for more details on how this parameter is used.

□ all_unreclaimable is used to report the unfortunate situation in which memory in all zones is currently completely unreclaimable. This can happen, for example, if all pages are pinned by the mlock system call.

□ The kernel can actively try to reclaim page clusters of a given page order. The order denotes that 2order contiguous pages are supposed to be reclaimed.

Higher-order allocations consisting of more than a single page are complicated to reclaim especially when the system has been up and running for some time. The kernel uses the lumpy reclaim trick — which could also well be called a dirty trick — to nevertheless satisfy such requests, as discussed below.

Before discussing the page-reclaiming code, recall that struct zone as introduced a long time ago in Chapter 3.2.2 contains numerous fields that will be required in the following:

Continue reading here: Info

Was this article helpful?

0 0