Checking Memory Utilization

Prior to swapping out pages, the kernel checks memory utilization to identify whether capacity is low. As when synchronizing pages, the kernel uses a combination of two mechanisms:

1. A periodic daemon (kswapd) runs in the background and repeatedly checks current memory utilization in order to initiate page swap-out when a particular threshold value is reached. This method ensures that no swap storms occur in which a very large number of pages suddenly need to be swapped out; this would result in long wait times and must be prevented on all accounts.

2. Nevertheless, the kernel must expect acute memory shortage whenever, for example, a large memory area is allocated by the buddy system or when buffers are generated. If insufficient RAM is available to satisfy the request for memory, the kernel must attempt to free space by swapping out pages as quickly as possible. Swap-out in the event of an acute emergency is part of direct reclaim.

The VM subsystem has only one option if a kernel request for memory cannot be satisfied even after pages have been swapped out — the targeted termination of a process by means of the OOM (out of memory) killer. Even if this sometimes entails severe losses, it is still better than a complete system crash, which would otherwise result.

Continue reading here: Selecting Pages to Be Swapped

Was this article helpful?

0 0