Библиотека сайта rus-linux.net
The book is available and called simply "Understanding The Linux Virtual Memory Manager". There is a lot of additional material in the book that is not available here, including details on later 2.4 kernels, introductions to 2.6, a whole new chapter on the shared memory filesystem, coverage of TLB management, a lot more code commentary, countless other additions and clarifications and a CD with lots of cool stuff on it. This material (although now dated and lacking in comparison to the book) will remain available although I obviously encourge you to buy the book from your favourite book store :-) . As the book is under the Bruce Perens Open Book Series, it will be available 90 days after appearing on the book shelves which means it is not available right now. When it is available, it will be downloadable from http://www.phptr.com/perens so check there for more information.
To be fully clear, this webpage is not the actual book.
Next: 11.5 Swapping Out Process Up: 11. Page Frame Reclamation Previous: 11.3 Manipulating the Page   Contents   Index
11.4 Shrinking all caches
The function responsible for shrinking the various caches is
shrink_caches()
which takes a few simple steps to
free up some memory. The maximum number of pages that will be
written to disk in any given pass is nr_pages
which
is initialised by try_to_free_pages_zone()
to be
SWAP_CLUSTER_MAX
11.1. The limitation is there so that if
kswapd schedules a large number of pages to be swapped to disk, it
will sleep occasionally to allow the IO to take place. As pages are freed,
nr_pages
is decremented to keep count.
The amount of work that will be performed also depends on the
priority
initialised by try_to_free_pages_zone()
to be DEF_PRIORITY
11.2. For each
pass that does not free up enough pages, the priority is decremented for
the highest priority been 1.
The function first calls kmem_cache_reap()
(see Section 9.1.7) which selects a slab cache to shrink. If nr_pages
number of pages are freed, the work is complete and the function returns
otherwise it will try to free nr_pages
from other caches.
If other caches are to be affected, refill_inactive()
will move
pages from the active_list
to the inactive_list
before shrinking the page cache by reclaiming pages at the end of the
inactive_list
with shrink_cache()
.
Finally, it shrinks three special caches, the dcache
(shrink_dcache_memory()
), the icache
(shrink_icache_memory()
) and the dqcache
(shrink_dqcache_memory()
). These objects are quite small in
themselves but a cascading effect allows a lot more pages to be freed in
the form of buffer and disk caches.
Footnotes
- ...
SWAP_CLUSTER_MAX
11.1 - Currently statically defined
as 32 in
mm/vmscan.c
. - ...
DEF_PRIORITY
11.2 DEF_PRIORITY
is currently statically defined as 6 inmm/vmscan.c
.
Next: 11.5 Swapping Out Process Up: 11. Page Frame Reclamation Previous: 11.3 Manipulating the Page   Contents   Index Mel 2004-02-15