From: Andrew Morton <akpm@osdl.org>
To: ajwade@cpe001346162bf9-cm0011ae8cd564.cpe.net.cable.rogers.com
Cc: andrew.j.wade@gmail.com, gfiala@s.netic.de, linux-kernel@vger.kernel.org
Subject: Re: large files unnecessary trashing filesystem cache?
Date: Tue, 18 Oct 2005 21:37:21 -0700 [thread overview]
Message-ID: <20051018213721.236b2107.akpm@osdl.org> (raw)
In-Reply-To: <200510182302.59604.ajwade@cpe001346162bf9-cm0011ae8cd564.cpe.net.cable.rogers.com>
Andrew James Wade <andrew.j.wade@gmail.com> wrote:
>
> Sometimes you want a single file to take up most of the memory; databases
> spring to mind. Perhaps files/processes that take up a large proportion of
> memory should be penalized by preferentially reclaiming their pages, but
> limit the aggressiveness so that they can still take up most of the memory
> if sufficiently persistent (and the rest of the system isn't thrashing).
Yes. Basically any smart heuristic we apply here will have failure modes.
For example, the person whose application does repeated linear reads of the
first 100MB of a 4G file will get very upset.
So any such change really has to be opt-in. Yes, it can be done quite
simply via repeated application of posix_fadvise(). But practically
speaking, it's very hard to get upstream GPL'ed applications changed, let
alone proprietary ones.
An obvious approach would be an LD_PRELOAD thingy which modifies read() and
write(), perhaps controlled via an environment variable. AFAIK nobody has
even attempted this.
For a kernel-based solution you could take a look at my old 2.4-based
O_STREAMING patch. It works OK, but it still needs modification of each
application (or an LD_PRELOAD hook into open()).
A decent kernel implementation would be to add a max_resident_pages to
struct file_struct and to use that to perform drop-behind within read() and
write(). That's a bit of arithmetic and a call to
invalidate_mapping_pages(). The userspace interface to that could be a
linux-specific extension to posix_fadvise() or to fcntl().
But that still requires that all the applications be modified.
So I'd also suggest a new resource limit which, if set, is copied into the
applications's file_structs on open(). So you then write a little wrapper
app which does setrlimit()+exec():
limit-cache-usage -s 1000 my-fave-backup-program <args>
Which will cause every file which my-fave-backup-program reads or writes to
be limited to a maximum pagecache residency of 1000 kbytes.
This facility could trivially be used for a mini-DoS: shooting down other
people's pagecache so their apps run slowly. But you can use fadvise() for
that already.
Or raise a patch against glibc's read() and write() which uses some
environment string to control fadvise-based invalidation. That's pretty
simple.
next prev parent reply other threads:[~2005-10-19 4:38 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-18 20:01 Guido Fiala
2005-10-18 20:48 ` Badari Pulavarty
2005-10-20 15:23 ` Guido Fiala
2005-10-19 3:02 ` Andrew James Wade
2005-10-19 4:37 ` Andrew Morton [this message]
2005-10-19 5:45 ` Andrew James Wade
2005-10-19 11:01 ` gfiala
2005-10-19 11:10 ` gfiala
2005-10-19 15:54 ` Ingo Oeser
2005-10-19 19:49 ` Andrew Morton
2005-10-19 22:26 ` Paul Jackson
2005-10-20 6:28 ` Ingo Oeser
2005-10-19 4:10 ` Lee Revell
2005-10-19 15:43 ` Badari Pulavarty
2005-10-19 17:58 ` Guido Fiala
2005-10-19 18:43 ` Kyle Moffett
2005-10-19 18:52 ` Guido Fiala
[not found] <4Z5WG-1iM-19@gated-at.bofh.it>
[not found] ` <4Z6zs-27l-39@gated-at.bofh.it>
2005-10-18 21:58 ` Bodo Eggert
2005-10-18 23:05 ` Badari Pulavarty
2005-10-19 0:20 ` David Lang
2005-10-19 0:33 ` Fawad Lateef
2005-10-19 1:42 ` Bernd Eckenfels
2005-10-19 7:23 ` Bodo Eggert
2005-10-19 11:06 ` gfiala
2005-10-19 13:43 ` Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20051018213721.236b2107.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=ajwade@cpe001346162bf9-cm0011ae8cd564.cpe.net.cable.rogers.com \
--cc=andrew.j.wade@gmail.com \
--cc=gfiala@s.netic.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®