From: Hugh Dickins <hugh@veritas.com>
To: Andrea Arcangeli <andrea@suse.de>
Cc: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>,
linux-kernel@vger.kernel.org, lhms-devel@lists.sourceforge.net
Subject: Re: [RFC] Changing COW detection to be memory hotplug friendly
Date: Thu, 10 Feb 2005 20:19:47 +0000 (GMT) [thread overview]
Message-ID: <Pine.LNX.4.61.0502101953190.6194@goblin.wat.veritas.com> (raw)
In-Reply-To: <20050210190521.GN18573@opteron.random>
On Thu, 10 Feb 2005, Andrea Arcangeli wrote:
>
> The reason pinned pages cannot be unmapped is that if they're being
> unmapped while a rawio read is in progress, a cow on some shared
> swapcache under I/O could happen.
>
> If a try_to_unmap + COW over a shared swapcache happens during a rawio
> read, then the rawio reads will get lost generating data corruption.
Yes, but...
get_user_pages broke COW in advance of the I/O. The reason for
subsequent COW if the page gets unmapped is precisely because
can_share_swap_page used page_count to judge exclusivity, and
get_user_pages has bumped that up, so the page appears (in danger
of being) non-exclusive when actually it is exclusive. By changing
can_share_swap_page to use page_mapcount, that frustration vanishes.
(Of course, if the process forks while async I/O is in progress,
these I/O pages could still get COWed, and either parent or child
lose some of the data being read - but behaviour in that case is
anyway undefined, isn't it? Just so long as kernel doesn't crash.)
> I had not much time to check the patch yet, but it's quite complex and
> could you explain again how do you prevent a cow to happen while the
> rawio is in flight if you don't pin the pte? The PG_locked bitflag
> cannot matter at all because the rawio read won't lock the page. What
> you have to prevent is the pte to be zeroed out, it must be kept
> writeable during the whole I/O. I don't see how you can allow unmapping
> without running into COWs later on.
The page_mapcount+page_swapcount test for exclusivity is simply a
better test for exclusivity than the page_count test. Since it says
exclusive when the page is exclusive, no COW occurs (and I've just
remembered that we're actually talking of the odd case where the
process itself writes into another portion of the page under I/O,
to get that write fault: but that still works).
page_count does still play a vital role, in ensuring that the page
stays held in the swapcache, cannot actually be reused for something
else while it's unmapped.
> This is the only thing I care to understand really, since it's the only
> case that the pte pinning was fixing.
>
> Overall I see nothing wrong in preventing memory removal while rawio is
> in flight. rawio cannot be in flight forever (ptrace and core dump as
> well should complete eventually). Why can't you simply drop pages from
> the freelist one by one until all of them are removed from the freelist?
I did ask Toshihiro about that earlier in the thread. Best look up his
actual reply, but as I understand it, his test is sufficiently thorough
that it's actually doing direct I/Os in parallel, so there's never a
moment when the page is free. He believes that an unprivileged process
should not be allowed to hold pages indefinitely unmigratable.
I have little appreciation of the hotplug/memmigration issues here.
But whatever the merits of that, I do think the new can_share_swap_page
is an improvement over the old (written in the days before page_mapcount
existed), and that it's preferable to remove the page_count heuristic
from try_to_unmap_one.
Hugh
next prev parent reply other threads:[~2005-02-10 20:20 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-03 3:56 IWAMOTO Toshihiro
2005-02-07 21:24 ` Hugh Dickins
2005-02-08 16:26 ` Hugh Dickins
2005-02-10 7:59 ` IWAMOTO Toshihiro
2005-02-10 19:05 ` Andrea Arcangeli
2005-02-10 19:16 ` Dave Hansen
2005-02-10 19:41 ` Andrea Arcangeli
2005-02-10 20:19 ` Hugh Dickins [this message]
2005-02-10 20:40 ` Andrea Arcangeli
2005-02-11 7:23 ` Hugh Dickins
2005-02-11 8:52 ` Andrea Arcangeli
2005-02-11 13:20 ` Hugh Dickins
2005-02-14 17:41 ` Andrea Arcangeli
2005-02-14 18:36 ` Hugh Dickins
2005-02-14 21:41 ` Andrea Arcangeli
2005-02-15 3:17 ` Andrew Morton
2005-02-09 9:08 ` IWAMOTO Toshihiro
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.0502101953190.6194@goblin.wat.veritas.com \
--to=hugh@veritas.com \
--cc=andrea@suse.de \
--cc=iwamoto@valinux.co.jp \
--cc=lhms-devel@lists.sourceforge.net \
--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®