The name swap daemon is a bit of a misnomer as the daemon
does more than just swap modified pages out to the swap file.
Its task is to keep
the memory management system operating efficiently.
The Kernel swap daemon (kswapd
kernel init process at startup time
and sits waiting for the kernel swap timer to periodically expire.
) is started by the
Every time the timer expires, the swap daemon looks to see if the number of
free pages in the system is getting too low.
Free pages in the system are too low if:
Linux does not want too many pages being written to the swap file at the same time so it uses nr_async_pages to keep count of the number of pages currently being written to the swap file. free_pages_low and free_pages_high are set at system startup time and are related to the number of physical pages in the system. If there are enough free pages, the swap daemon sleeps until its timer expires again, otherwise the swap daemon tries three ways to reduce the number of physical pages being used by the system: