2003-01-19 16:57:04

by Jean-Eric Cuendet

[permalink] [raw]
Subject: Disabling file system caching

Hi,
Is it possible to disable file caching for a given partition or mount?
Or at least to limit it at a certain quantity of memory?
I think of a BIG compilation (several GB of files) and would tell gcc to
not cache the compiled files.
Thanks
-jec



2003-01-20 00:56:20

by Rik van Riel

[permalink] [raw]
Subject: Re: Disabling file system caching

On Sun, 19 Jan 2003, Jean-Eric Cuendet wrote:

> Is it possible to disable file caching for a given partition or mount?

No, if you do that mmap(), read(), write() etc. would be impossible.

> Or at least to limit it at a certain quantity of memory?

Not yet. I'm thinking of implementing something like this
for the next version of -rmap (reclaim only from the cache
if the cache occupies more than a certain fraction of ram).

> I think of a BIG compilation (several GB of files) and would tell gcc to
> not cache the compiled files.

But what about the .h files ? You will want to cache those.

regards,

Rik
--
Bravely reimplemented by the knights who say "NIH".
http://www.surriel.com/ http://guru.conectiva.com/
Current spamtrap: <a href=mailto:"[email protected]">[email protected]</a>

2003-01-20 07:41:05

by Balbir

[permalink] [raw]
Subject: Re: Disabling file system caching

Not sure if posting to the newsgroup linux.kernel sends
it to the mailing list too.

"Balbir Singh" <[email protected]> wrote in message
news:[email protected]...
> "Rik van Riel" <[email protected]> wrote in message
> news:[email protected]...
> > On Sun, 19 Jan 2003, Jean-Eric Cuendet wrote:
> >
> > > Is it possible to disable file caching for a given partition or mount?
> >
> > No, if you do that mmap(), read(), write() etc. would be impossible.
> >
> > > Or at least to limit it at a certain quantity of memory?
> >
> > Not yet. I'm thinking of implementing something like this
> > for the next version of -rmap (reclaim only from the cache
> > if the cache occupies more than a certain fraction of ram).
>

I think that this feature is very important. In an embedded system
using an NFS root filesystem, we found that the file cache
would take a lot of memory and all insmods would fail. This is
especially true when the system boots up and looks for /lib/modules.

I think it should be possible to modify the slab allocator to
implement a memory pool. We could add a flag which would prevent
the slab from growing beyond its initial size.

This approach would work only if the cache is allocated by
using the slab allocator.

Balbir



2003-01-20 12:44:21

by martin.knoblauch

[permalink] [raw]
Subject: Re: Disabling file system caching

> Re: Disabling file system caching
>
> From: Rik van Riel ([email protected])
> Date: Sun Jan 19 2003 - 20:05:00 EST
>
> On Sun, 19 Jan 2003, Jean-Eric Cuendet wrote:
>
> > Is it possible to disable file caching for a given partition or mount?
>
> No, if you do that mmap(), read(), write() etc. would be impossible.
>
> > Or at least to limit it at a certain quantity of memory?
>
> Not yet. I'm thinking of implementing something like this
> for the next version of -rmap (reclaim only from the cache
> if the cache occupies more than a certain fraction of ram).
>

Yes please !!!
Yes please !!!
Yes please !!!

:-)

Having a maximum [and maybe minimum] knob for controlling the cache
would be an extremely useful feature in some situations.

Martin

2003-01-20 14:12:23

by Jan Hudec

[permalink] [raw]
Subject: Re: Disabling file system caching

On Mon, Jan 20, 2003 at 01:17:42PM +0530, Balbir wrote:
> Not sure if posting to the newsgroup linux.kernel sends
> it to the mailing list too.
>
> "Balbir Singh" <[email protected]> wrote in message
> news:[email protected]...
> > "Rik van Riel" <[email protected]> wrote in message
> > news:[email protected]...
> > > On Sun, 19 Jan 2003, Jean-Eric Cuendet wrote:
> > >
> > > > Is it possible to disable file caching for a given partition or mount?
> > >
> > > No, if you do that mmap(), read(), write() etc. would be impossible.
> > >
> > > > Or at least to limit it at a certain quantity of memory?
> > >
> > > Not yet. I'm thinking of implementing something like this
> > > for the next version of -rmap (reclaim only from the cache
> > > if the cache occupies more than a certain fraction of ram).
> >
>
> I think that this feature is very important. In an embedded system
> using an NFS root filesystem, we found that the file cache
> would take a lot of memory and all insmods would fail. This is
> especially true when the system boots up and looks for /lib/modules.
>
> I think it should be possible to modify the slab allocator to
> implement a memory pool. We could add a flag which would prevent
> the slab from growing beyond its initial size.
>
> This approach would work only if the cache is allocated by
> using the slab allocator.

No, it's not! And the slab alocator should mercilessly rip the cache
when it needs some pages. In the NFS root case, I would guess it's
a problem of NFS implementation allocating too much kernel memory, since
both cache and user-land pages are riped in favor of kernel allocations.

-------------------------------------------------------------------------------
Jan 'Bulb' Hudec <[email protected]>

2003-01-20 19:40:52

by folkert

[permalink] [raw]
Subject: RE: Disabling file system caching

> > Is it possible to disable file caching for a given partition or mount?
> No, if you do that mmap(), read(), write() etc. would be impossible.

Hmmm, maybe there's some way to explicitly flush the read/write-cache?
Ok, sync will do nice for the write-cache, but for the read-one?


2003-01-20 21:30:27

by Nuno Silva

[permalink] [raw]
Subject: Re: Disabling file system caching



Folkert van Heusden wrote:
>>>Is it possible to disable file caching for a given partition or mount?
>>
>>No, if you do that mmap(), read(), write() etc. would be impossible.
>
>
> Hmmm, maybe there's some way to explicitly flush the read/write-cache?
> Ok, sync will do nice for the write-cache, but for the read-one?

AFAIK, you simply can't... I'm trying to do this for several months and
no luck. Linux simply caches everything it can in the read-cache. For
99% of all cases this is very good but, for some situations, this is not
desireable.

For the write cache, you can minimize memory usage playing with
/proc/sys/vm (see Documentation/filesystems/proc.txt).

Regards,
Nuno Silva

>
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>