(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version




Main Index

See also Invalidating the Linux buffer cache

From: "Tony  Lawrence" <pcu...@gmail.com>
Subject: Re: Is there a way to flush the file cache?
Date: 29 Dec 2006 04:06:58 -0800
Message-ID: <1167394018.640695.74170@73g2000cwn.googlegroups.com> 
References: <4vig1lF1b4vglU18@mid.individual.net> 


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?

O, I see now:  you are checking disk performance or maybe even checking
disk integrity.

No, sync won't help with that (because the read can still come from
cache).  What you need to do is overwrite the cache with new data
unrelated to the blocks you want to read.  That could be as simple as a
well placed "ls -lR".. or much more complex.  See

http://www.linuxjournal.com/article/7105

Apparently newer kernels have made this easier:

http://linux-mm.org/Drop_Caches

  
-- 
Tony Lawrence
Unix/Linux/Mac OS X Resources
http://aplawrence.com
 



Click here to add your comments



Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments


If you want a picture to show with your comment, go get a Gravatar

cartoon


/Bofcusm/2656.html copyright 1997-2004 (various authors) All Rights Reserved

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

Jump to Comments



Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.



More:
       - OSR5
       - Bofcusm


Unix/Linux Consultants

Skills Tests

Guest Post Here











My Favorites

Change Congress