Page frames can be freed in several possible ways:
By reclaiming an unused page frame within a cache. Depending on the type of cache, the following functions are used:
By swapping out a page belonging to an anonymous memory region of a process or a modified page belonging to a private memory mapping.
By swapping out a page belonging to an IPC shared memory region.
As we shall see shortly, the choice among these possibilities is done in a rather empirical way, with very little support from theory. The situation is somewhat similar to evaluating the factors that determine the dynamic priority of a process. The main objective is to get a tuning of the parameters that achieve good system performance, without asking too many questions about why it works.
Besides the nr_free_pages variable, which expresses the current number of free page frames, the kernel relies on two values, a kind of low and high watermark. These values are stored in a structure called freepages (it also has a low field that is no longer used in Linux 2.2):
Minimum number of page frames reserved to the kernel to perform crucial operations (e.g., for swapping pages to disk). (free_area_init( ) initializes this field to 2n, where n denotes the size of primary ...