struct swap_list_t {

int head; /* head of priority-ordered swapfile list */

head is an index into the swap_info[] array and is used to select the swap area with the highest priority. The kernel works its way through the list to the swap areas with low priorities using the next elements. next is used to implement a round robin process to uniformly fill multiple swap areas with pages if the areas have the same priority. I return to this variable below when I examine how the kernel selects swap pages.

Let us take a close look at the system's mode of operation by reference to the example above. The entry point is the first array entry that contains the swap area with the highest priority. The value of head is therefore 0.

next specifies which swap area is used next. This need not always be the swap area with the highest priority. If the latter is already full, next points to another swap area.

□ In order to reduce search times when the complete swap area is scanned for a free slot, the kernel manages the upper and lower limits of the search zone with the aid of the lowest_bit and highest_bit elements. There are no free pages above or below these positions so it would be pointless to search this area.

Although the names of the two variables end with _bit, they are not bit fields but absolutely normal integers that are interpreted as indexes with regard to the linearly arranged pages of a swap area.

□ The kernel also provides two elements — cluster_next and cluster_nr — to implement the cluster technique mentioned briefly above. The former specifies which slot of an existing cluster in the swap area is to be used next, and cluster_nr indicates how many pages are still available for use in the current cluster before it is necessary to start a new cluster, or (if not enough free pages are available for a new cluster) that recourse is made to fine-grained allocation.

Continue reading here: Extents for Implementing Non Contiguous Swap Areas

Was this article helpful?

0 0