mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hugh Dickins <hugh@veritas.com>
To: Blaisorblade <blaisorblade@yahoo.it>
Cc: akpm@osdl.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: remove-stale-comment-from-swapfilec.patch added to -mm tree
Date: Fri, 26 Aug 2005 20:23:46 +0100 (BST)	[thread overview]
Message-ID: <Pine.LNX.4.61.0508262012210.8803@goblin.wat.veritas.com> (raw)
In-Reply-To: <200508262017.38301.blaisorblade@yahoo.it>

On Fri, 26 Aug 2005, Blaisorblade wrote:
> On Wednesday 24 August 2005 15:26, Hugh Dickins wrote:
> 
> > If do_swap_page gets 
> > a write fault, it either determines it can go ahead and use the swap
> > page, or if it can't, gets do_wp_page to Copy-On-Write for it (that's
> > a call I added in 2.6.7, as an optimization, and as a necessity for
> > correct behaviour of ptrace's get_user_pages; the latter has just in
> > 2.6.13-rc been made more resilient, so we could remove do_swap_page's
> > call to do_wp_page now - though I'm inclined to let it stay as an
> > optimization, avoiding the second fault which would follow).
> get_user_pages() can still get two faults there, because VM_FAULT_WRITE is not 
> returned by do_swap_page(). And faults can be very expensive (for UML a fault 
> is given by a SIGSEGV delivery).

You're right that it can get two "faults" there, but it's such a rare case
(ptrace modifying an area readonly to the process) that I didn't bother
about it.  It isn't even two real faults, just two iterations within
get_user_pages - or does that somehow get worse in the UML case?

> > If do_swap_page gets a read fault, it doesn't COW at all.
> 
> > I don't know what the "early" COW break referred to is: the write_access
> > call to do_wp_page could be deferred, yes, but it's hardly early.
> The idea in my mind is that after loading the page from swap the first time 
> there's no need to copy the page to give a private copy to the process, if 
> the page is kept on swap.
> 
> We COW it anyway to break the sharing, to keep the original copy in the 
> swapcache, instead of reading it again from the disk. This is *early*. 

We always prefer not to read from the disk.  You're right that we could
choose to remove the page from the swap cache at that point (locking
considerations?) and make it private (in the case where it has actually
been written to the disk, often not yet so), but that's not how the page
cache has ever been treated.  Avoid going to slow disk at all costs.

Hugh

      reply	other threads:[~2005-08-26 19:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200508172149.j7HLn37L012796@shell0.pdx.osdl.net>
     [not found] ` <Pine.LNX.4.61.0508241335390.4198@goblin.wat.veritas.com>
2005-08-26 18:17   ` Blaisorblade
2005-08-26 19:23     ` Hugh Dickins [this message]

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=Pine.LNX.4.61.0508262012210.8803@goblin.wat.veritas.com \
    --to=hugh@veritas.com \
    --cc=akpm@osdl.org \
    --cc=blaisorblade@yahoo.it \
    --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®