Clearing the I/O caches? (for benchmark tests)

Tom M. Kroeger (tmk@cse.ucsc.edu)
13 Jul 1999 16:10:38 -0700


What is the best way to clear the various I/O caches?

I am trying to test a modified prefetching algorithm I've been working
on, and would like to clear all of the disk data from the various
memory caches (dcache, page cache, inode and buffer). I've set up an
script to run a basic benchmark test (a build of some code) and record
various performance measures. What I'm looking for is the best way to
clear the various I/O caches in between each run of this test without
having to reboot each time. Additionally, I'd like the option of
leaving the dcache in tact while clearing the other caches as much as
possible.

My problem is that while I'm able to apparently clear the page
directory and inode caches, I'm unable to completely clear the buffer
cache. This is indicated by the fact that my benchmark sees a buffer
cache hit ratio of 74% right after a reboot, but after the test has
been run once I'm unable to get the buffer cache hit ratio below 78%.
I understand that data that some data (e.g. open file meta data) can't
be cleared, but once my benchmark test is finished, all of the data
should be unlocked and freeable? correct?

I'm using the 2.2.7 kernel and Debian 2.1 and have tried the following
things:

1) A programs that allocates all memory and using tail -f /dev/zero to
allocate all memory? Both of these seem to clear most of the data,
but don't seem to clear all of the data even when I change the minimum
value in /proc/sys/vm/buffermem. Occasionally this causes klogd and
syslogd to die because they are not able to allocate memory and gotten
me into a state where I need to use alt-SysReq-xxx to sync, unmount
and reboot. This also doesn't allow me to leave the dcache un-emptied.

2) Calling prune_dcache(0) to clear the dcache, page cache and inode
cache? This seems to be effective with clearing the dcache and
freeing up inodes and pages.

3) calling sys_sync and then a modified invalidate_buffers
that doesn't check for a specific device number?

4) a modified shrink_mmap() -- that goes through each page
and tries to free it based on what it is used as (calling
try_to_free_buffer or remove_inode_page)

These both seemed to remove some but not all of the buffer cache data.

In any event thanks for everyones time,

-- 

tmk

----------------------------------------------------------------------- Tom M. Kroeger Pray for wind Graduate Student, UC Santa Cruz \ Pray for waves e-mail: tmk@cs.ucsc.edu |\ and Pray it's your day off! http://www.cse.ucsc.edu/~tmk |~\ (831) 459-4458 |__\ (831) 426-9055 home ,----+--

- 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/