linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Rik van Riel <riel@redhat.com>
To: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	Johannes Weiner <hannes@saeurebad.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Nossum <vegard.nossum@gmail.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH -mm] mm: more likely reclaim MADV_SEQUENTIAL mappings
Date: Mon, 21 Jul 2008 23:04:05 -0400	[thread overview]
Message-ID: <20080721230405.6cfde9bd@bree.surriel.com> (raw)
In-Reply-To: <200807221254.28473.nickpiggin@yahoo.com.au>

On Tue, 22 Jul 2008 12:54:28 +1000
Nick Piggin <nickpiggin@yahoo.com.au> wrote:
> On Tuesday 22 July 2008 12:36, Rik van Riel wrote:
> > On Tue, 22 Jul 2008 12:02:26 +1000
> >
> > Nick Piggin <nickpiggin@yahoo.com.au> wrote:
> > > I don't actually care what the man page or posix says if it is obviously
> > > silly behaviour. If you want to dispute the technical points of my post,
> > > that would be helpful.
> >
> > Application writers read the man page and expect MADV_SEQUENTIAL
> > to do roughly what the name and description imply.
> >
> > If you think that the kernel should not bother implementing
> > what the application writers expect, and the application writers
> > should implement special drop-behind magic for Linux, your
> > expectations may not be entirely realistic.
> 
> The simple fact is that if you already have the knowledge and custom
> code for sequentially accessed mappings, then if you know the pages
> are not going to be used, there is a *far* better way to do it by
> unmapping them than the kernel will ever be able to do itself.

Applications are not developed just for Linux.

Application writers expect MADV_SEQUENTIAL to behave
a certain way and this 5 line patch implements that.

> Also, it would be perfectly valid to want a sequentially accessed
> mapping but not want to drop the pages early.

That is exactly what Johannes' patch does.  All it does is
change the behaviour of pages that have already reached the
end of the LRU lists.

It does not do any kind of early drop-behind or other strange
magic.

> > > Consider this: if the app already has dedicated knowledge and
> > > syscalls to know about this big sequential copy, then it should
> > > go about doing it the *right* way and really get performance
> > > improvement. Automatic unmap-behind even if it was perfect still
> > > needs to scan LRU lists to reclaim.
> >
> > Doing nothing _also_ ends up with the kernel scanning the
> > LRU lists, once memory fills up.
> 
> But we are not doing nothing because we already know and have coded
> for the fact that the mapping will be accessed once, sequentially.
> Now that we have gone this far, we should actually do it properly and
> 1. unmap after use, 2. POSIX_FADV_DONTNEED after use. This will give
> you much better performance and cache behaviour than any automatic
> detection scheme, and it doesn't introduce any regressions for existing
> code.

If you run just one instance of the application!

Think about something like an ftp server or a media server,
where you want to cache the data that is served up many
times, while evicting the data that got served just once.

The kernel has much better knowledge of what the aggregate
of all processes in the system are doing than any individual
process has.

> > Scanning the LRU lists is a given.
> 
> It is not.

Regardless of whether or not the application unmaps the pages
by itself, the pages will still be on the LRU lists.

-- 
All rights reversed.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2008-07-22  3:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-19 17:31 Johannes Weiner
2008-07-19 17:59 ` Rik van Riel
2008-07-21  0:09 ` KOSAKI Motohiro
2008-07-21  1:48   ` Andrew Morton
2008-07-21  3:53     ` KOSAKI Motohiro
2008-07-21  5:49     ` Nick Piggin
2008-07-21 15:14       ` Rik van Riel
2008-07-22  2:02         ` Nick Piggin
2008-07-22  2:36           ` Rik van Riel
2008-07-22  2:54             ` Nick Piggin
2008-07-22  3:04               ` Rik van Riel [this message]
2008-07-22  3:43                 ` Nick Piggin
2008-07-22  3:49                   ` Nick Piggin

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=20080721230405.6cfde9bd@bree.surriel.com \
    --to=riel@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@saeurebad.de \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nickpiggin@yahoo.com.au \
    --cc=peterz@infradead.org \
    --cc=vegard.nossum@gmail.com \
    /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