Re: Is there a way to flush the file cache?



General Schvantzkoph wrote:
On Thu, 28 Dec 2006 13:29:24 -0800, Tony Lawrence wrote:

General Schvantzkoph wrote:
I'm writing a system exerciser that checks memory and disk I/O. Is there a
C call that flushes the file cache so that I can be assured that my freads
are coming from the disk and not the RAM. I'm using a sync() but I don't
think that does the whole job, it guarantees that the disk writes happen
but I don't think it clears out the file cache.

Well, of course it can't guarantee that some random app hasn't written
data, if that's what you mean..


What I want to do is the following,

1) Create a file and write it to the disk.
2) Read that file off of the disk and then check it.

I'm trying to check the SATA interfaces so it's important that the file go
to and from the disks. The file cache interferes with this because if the
file is present in the cache the program will get the cached copy not the
copy that is on the disk. The sync() call forces the disk writes to happen
immediately which is half of the battle. The other half is to purge the
file cache so that all subsequent file reads come from the disk. Is there
a way to do this?

Does your version of the kernel permit "raw IO"? The 2.4 kernels do. In that
case, you can open a raw partition and reads and writes will bypass the file
system and use just the device drivers. I believe the 2.6 kernels do not
unless you have some computability library or something.

--
.~. Jean-David Beyer Registered Linux User 85642.
/V\ PGP-Key: 9A2FC99A Registered Machine 241939.
/( )\ Shrewsbury, New Jersey http://counter.li.org
^^-^^ 07:30:01 up 69 days, 10:02, 3 users, load average: 4.48, 4.25, 4.18
.



Relevant Pages

  • Re: non_blocking question
    ... Physical Disk Sustained Write Peformance ... For files to typical Linux filesystem (e.g. ... Processor Interrupt Handling ... bypassing the file cache. ...
    (comp.unix.programmer)
  • IA64 Linux VM performance woes.
    ... SGI ProPack 2.4 for Linux, ... We have been experiencing bad performance and downright bad behavior when we ... At first the throughtput we are getting without file cache bypass is at around ... Control the amount of data flushed out to disk in set time periods; ...
    (comp.sys.sgi.admin)
  • IA64 Linux VM performance woes.
    ... SGI ProPack 2.4 for Linux, ... We have been experiencing bad performance and downright bad behavior when we ... At first the throughtput we are getting without file cache bypass is at around ... Control the amount of data flushed out to disk in set time periods; ...
    (Linux-Kernel)
  • Re: Is there a way to flush the file cache?
    ... C call that flushes the file cache so that I can be assured that my freads ... are coming from the disk and not the RAM. ... The file cache interferes with this because if the ... The sync() call forces the disk writes to happen ...
    (comp.os.linux.misc)
  • Re: Is there a way to flush the file cache?
    ... C call that flushes the file cache so that I can be assured that my freads ... are coming from the disk and not the RAM. ... Does your version of the kernel permit "raw IO"? ... I believe the 2.6 kernels do not ...
    (comp.os.linux.misc)