[patch] shrink_mmap shrink all the buffer cache

Andrea Arcangeli (andrea@suse.de)
Wed, 4 Aug 1999 02:58:39 +0200 (CEST)

Currently shrink_mmap doesn't consider a progress freeing a metadata
(or anonymous) buffer page. The bad behaviour can be noticed simply by
running something like:

cp /dev/hda /dev/null

and monitoring the buffer size in the meantime. The buffer size will grow
up to eat all free memory and then it will be shrunk close to zero each
time shrink_mmap triggers.

This patch below should fix the problem:

--- 2.3.12/mm/filemap.c Thu Jul 22 01:07:28 1999
+++ /tmp/filemap.c Wed Aug 4 02:45:44 1999
@@ -294,11 +294,15 @@

/* Is it a buffer page? */
if (page->buffers) {
- int mem = page->inode ? 0 : PAGE_CACHE_SIZE;
if (!try_to_free_buffers(page))
goto unlock_continue;
- atomic_sub(mem, &buffermem);
+ /* page was locked, inode can't go away under us */
+ if (!page->inode)
+ {
+ atomic_sub(PAGE_CACHE_SIZE, &buffermem);
+ goto made_progress;
+ }

I also changed the inode check since it looks cleaner to me the way above.
The page is locked so the inode can't change under us.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/