Implementing the PFRA

The page frame reclaiming algorithm must take care of many kinds of pages owned by User Mode processes, disk caches and memory caches; moreover, it has to obey several heuristic rules. Thus, it is not surprising that the PFRA is composed of a large number of functions. Figure 17-3 shows the main PFRA functions; an arrow denotes a function invocation, thus for instance try_to_free_pages( ) invokes shrink_caches( ), shrink_slab( ), and out_of_memory( ).

As you can see, there are several “entry points” for the PFRA. Actually, page frame reclaiming is performed on essentially three occasions:

Low on memory reclaiming

The kernel detects a “low on memory” condition.

Hibernation reclaiming

The kernel must free memory because it is entering in the suspend-to-disk state (we don’t further discuss this case).

Periodic reclaiming

A kernel thread is activated periodically to perform memory reclaiming, if necessary.

The main functions of the PFRA

Figure 17-3. The main functions of the PFRA

Low on memory reclaiming is activated in the following cases:

Get Understanding the Linux Kernel, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.