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

Jamie Lokier (lkd@tantalophile.demon.co.uk)
Wed, 14 Jul 1999 22:06:22 +0200


Stephen C. Tweedie wrote:
> Nearly. The ext2 filesystem keeps a cache of recently-accessed bitmap
> buffers pinned in memory, and once that cache is primed you can't flush
> it unless you unmount the filesystem. If you have any processes still
> cd'ed to the active filesystem, then they will also be keeping directory
> inodes pinned in the inode cache.

I use the following script to flush I/O caches for benchmarks.
Does it suffer from the same problem?

thanks,
-- Jamie

#!/bin/sh

# Linux only!
# Flush inode, dentry and buffer cache of all mounted filesystems.
# Must be run as root.
#
# -- Jamie Lokier, March 1999

case "`id -u`" in
0) ;;
*) echo Only root can run this script. 1>&2; exit 1 ;;
esac

mount | sort -k3 -r | \
while read dev ON dir TYPE type etc; do
echo mount $dir -o remount
mount $dir -o remount
done

mount | sort -k1 | \
while read dev ON dir TYPE type etc; do
case "$dev" in
/dev/*) echo hdparm -f $dev
hdparm -f $dev >/dev/null ;;
esac
done

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