next up previous contents
Next: Swapping Out Shared Pages Up: Swapping and Discarding Pages Previous: Swapping Pages Out

Reducing the Size of the Page and Buffer Caches

  Each time the Kernel swap daemon tries to shrink these caches

it examines a number of pages in the mem_map  page vector too see if any can be discarded from physical memory. The number of pages examined is defined by the priority the code is called at. The blocks of pages are examined in a cyclical manner; a different block of pages is examined each time an attempt is made to shrink the memory map.

Each page being examined is checked to see if it is cached in either the page cache or the buffer cache. You should note that shared pages are not considered for discarding at this time and that a page cannot be in both caches at the same time. If the page is not in either cache then the next page in the mem_map  page vector is examined.

Pages are cached in the buffer cache (or rather the buffers within the pages are cached) to make buffer allocation and deallocation more efficient. The memory map shrinking code tries to free the buffers that are contained within the page being examined.

If the all the buffers are freed, then the pages that contain them are also be freed.

Pages are queued in the page cache to speed up access to images and data on disk. If the examined page is in this cache, it is removed from the page cache and freed.

When enough pages have been freed on this attempt then the kernel swap daemon will wait until the next time it is periodically woken. As none of the freed pages were part of any process's virtual memory (they were cached pages), then no page tables need updating. If there were not enough cached pages discarded then the swap daemon will try to swap out some shared pages.


next up previous contents
Next: Swapping Out Shared Pages Up: Swapping and Discarding Pages Previous: Swapping Pages Out

David A. Rusling
david.rusling@reo.mts.dec.com