The later section Section 16.7 explains what happens when pages are swapped out. As we indicated at the beginning of this chapter, swapping out pages is a last resort and appears as part of a general strategy to free memory that uses other tactics as well. In this section, we show how the kernel performs a swap out. This is achieved by a series of functions called in cascading fashion. Let's start with the functions at the higher level.
The swap_out( ) function acts on a single classzone parameter that specifies the memory zone from which pages should be swapped out (see Section 7.1.2). Two other parameters, priority and gfp_mask, are not used.
The swap_out( ) function scans existing memory descriptors and tries to swap out the pages referenced in each process's Page Tables. It terminates as soon as one of the following conditions occurs:
• The function succeeds in releasing swap_cluster_max page frames (by default, 32). A page frame is considered released when it is removed from the Page Tables of all processes that share it.
• The function scans n memory descriptors, where n is the length of the memory descriptor list when the function starts. [5I
Was this article helpful?