Using madvise for ld.so
Andrew Morton
akpm at osdl.org
Wed Mar 17 19:21:39 CET 2004
Michael Matz <matz at kde.org> wrote:
>
> Hi Andrew,
>
> On Tue, 16 Mar 2004, Andrew Morton wrote:
>
> > > On Tue, 16 Mar 2004 21:00:26 +0100, Dirk Mueller <mueller at kde.org> wrote:
> > > > might be a stupid question, but how did you "clear the cache" ?
> > >
> > > the usual "use memory till oom" thing (included in an earlier email iirc)
> > > i wish the kernel guys would sort this out which a proper solution.
> >
> > In 2.6 you can run posix_fadvise(fd, start, length, POSIX_FADV_DONTNEED).
> >
> > I've attached a little proggy which uses fadvise to shoot down some or all
> > of a file's pagecache.
>
> This is only for one file, though. I.e. one would need to do /proc
> parsing magic to really clean the whole file cache (for all files not open
> anymore). I think the "alloc all mem, touch all pages" approach is
> easier ;)
True.
You want to kill all pagecache to simulate cold startup? No, we don't have
a way of doing that apart from the force-a-swapstorm approach which you're
using. That's more valid anyway, because it will also cause reclaim of the
inode and directory entry caches.
> Which reminds me of a question I asked myself: If I open the file, fadvise
> a WILLNEED on it, all its pages are scheduled for IO. Completion is not
> waited for. So, if the program then exits, the file gets closed, and
> assuming that was the last ref to that inode: will the not yet completed
> IO be canceled or will it still be completed?
The I/O will not be cancelled.
More information about the Kde-optimize
mailing list