From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: kosaki.motohiro@jp.fujitsu.com,
Andrea Arcangeli <aarcange@redhat.com>,
LKML <linux-kernel@vger.kernel.org>,
Linus Torvalds <torvalds@osdl.org>, Andrew Morton <akpm@osdl.org>,
Jeff Moyer <jmoyer@redhat.com>,
linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
Hugh Dickins <hugh@veritas.com>
Subject: Re: [RFC][PATCH v3 1/6] mm: Don't unmap gup()ed page
Date: Wed, 15 Apr 2009 17:05:54 +0900 (JST) [thread overview]
Message-ID: <20090415165431.AC4C.A69D9226@jp.fujitsu.com> (raw)
In-Reply-To: <200904150042.15653.nickpiggin@yahoo.com.au>
Hi
> On Wednesday 15 April 2009 00:32:52 Andrea Arcangeli wrote:
> > On Wed, Apr 15, 2009 at 12:26:34AM +1000, Nick Piggin wrote:
> > > Andrea: I didn't veto that set_bit change of yours as such. I just
> >
> > I know you didn't ;)
> >
> > > noted there could be more atomic operations. Actually I would
> > > welcome more comparison between our two approaches, but they seem
> >
> > Agree about the welcome of comparison, it'd be nice to measure it the
> > enterprise workloads that showed the gup_fast gain in the first place.
>
> I think we should be able to ask IBM to run some tests, provided
> they still have machines available to do so. Although I don't want
> to waste their time so we need to have something that has got past
> initial code review and has a chance of being merged.
>
> If we get that far, then I can ask them to run tests definitely.
Oh, it seem very charming idea.
Nick, I hope to help your patch's rollup. It makes good comparision, I think.
Is there my doable thing?
And, I changed my patch.
How about this? I added simple twice check.
because, both do_wp_page and try_to_unmap_one grab ptl. then,
page-fault routine can't change pte while try_to_unmap nuke pte.
---
mm/rmap.c | 30 ++++++++++++++++++++++++------
mm/swapfile.c | 3 ++-
2 files changed, 26 insertions(+), 7 deletions(-)
Index: b/mm/swapfile.c
===================================================================
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -547,7 +547,8 @@ int reuse_swap_page(struct page *page)
SetPageDirty(page);
}
}
- return count == 1;
+
+ return count + page_count(page) == 2;
}
/*
Index: b/mm/rmap.c
===================================================================
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -772,12 +772,18 @@ static int try_to_unmap_one(struct page
if (!pte)
goto out;
- /*
- * If the page is mlock()d, we cannot swap it out.
- * If it's recently referenced (perhaps page_referenced
- * skipped over this mm) then we should reactivate it.
- */
if (!migration) {
+ if (PageSwapCache(page) &&
+ page_count(page) != page_mapcount(page) + 2) {
+ ret = SWAP_FAIL;
+ goto out_unmap;
+ }
+
+ /*
+ * If the page is mlock()d, we cannot swap it out.
+ * If it's recently referenced (perhaps page_referenced
+ * skipped over this mm) then we should reactivate it.
+ */
if (vma->vm_flags & VM_LOCKED) {
ret = SWAP_MLOCK;
goto out_unmap;
@@ -790,7 +796,19 @@ static int try_to_unmap_one(struct page
/* Nuke the page table entry. */
flush_cache_page(vma, address, page_to_pfn(page));
- pteval = ptep_clear_flush_notify(vma, address, pte);
+ pteval = ptep_clear_flush(vma, address, pte);
+
+ if (!migration) {
+ /* re-check */
+ if (PageSwapCache(page) &&
+ page_count(page) != page_mapcount(page) + 2) {
+ /* We lose race against get_user_pages_fast() */
+ set_pte_at(mm, address, pte, pteval);
+ ret = SWAP_FAIL;
+ goto out_unmap;
+ }
+ }
+ mmu_notifier_invalidate_page(vma->vm_mm, address);
/* Move the dirty bit to the physical page now the pte is gone. */
if (pte_dirty(pteval))
--
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>
next prev parent reply other threads:[~2009-04-15 8:05 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-14 6:15 [RFC][PATCH 0/6] IO pinning(get_user_pages()) vs fork race fix KOSAKI Motohiro
2009-04-14 6:16 ` [RFC][PATCH v3 1/6] mm: Don't unmap gup()ed page KOSAKI Motohiro
2009-04-14 9:25 ` Nick Piggin
2009-04-14 12:02 ` KOSAKI Motohiro
2009-04-14 12:25 ` Nick Piggin
2009-04-14 13:39 ` KOSAKI Motohiro
2009-04-14 14:12 ` Andrea Arcangeli
2009-04-14 14:26 ` Nick Piggin
2009-04-14 14:32 ` Andrea Arcangeli
2009-04-14 14:42 ` Nick Piggin
2009-04-14 15:21 ` Andrea Arcangeli
2009-04-15 8:05 ` KOSAKI Motohiro [this message]
2009-04-15 8:22 ` Nick Piggin
2009-04-15 9:22 ` Nick Piggin
2009-04-15 10:46 ` Andrea Arcangeli
2009-04-15 11:39 ` KOSAKI Motohiro
2009-04-15 11:41 ` Andrea Arcangeli
2009-04-15 11:53 ` KOSAKI Motohiro
2009-04-19 12:37 ` KOSAKI Motohiro
2009-04-14 14:38 ` Andrea Arcangeli
2009-04-14 6:18 ` [RFC][PATCH v3 2/6] mm, directio: fix fork vs direct-io race (read(2) side IOW gup(write) side) KOSAKI Motohiro
2009-04-14 6:25 ` KOSAKI Motohiro
2009-04-14 16:45 ` Jeff Moyer
2009-04-14 17:51 ` Andrea Arcangeli
2009-04-14 18:10 ` Jeff Moyer
2009-04-14 19:48 ` Andrea Arcangeli
2009-04-14 6:19 ` [RFC][PATCH v3 3/6] nfs, direct-io: fix fork vs direct-io race on nfs KOSAKI Motohiro
2009-04-14 16:48 ` Jeff Moyer
2009-04-14 6:20 ` [RFC][PATCH v3 4/6] aio: Don't inherit aio ring memory at fork KOSAKI Motohiro
2009-04-14 13:41 ` Andrea Arcangeli
2009-04-14 16:01 ` Jeff Moyer
2009-04-15 0:56 ` KOSAKI Motohiro
2009-04-15 2:44 ` Jeff Moyer
2009-04-15 3:00 ` KOSAKI Motohiro
2009-04-14 6:21 ` [RFC][PATCH v3 5/6] don't use bio-map in read() path KOSAKI Motohiro
2009-04-14 6:23 ` [RFC][PATCH v3 6/6] fix wrong get_user_pages usage in iovlock.c KOSAKI Motohiro
2009-04-14 6:56 ` Nick Piggin
2009-04-14 6:58 ` KOSAKI Motohiro
2009-04-15 8:48 ` KOSAKI Motohiro
2009-04-17 15:07 ` Sosnowski, Maciej
2009-04-19 12:37 ` KOSAKI Motohiro
2009-04-23 12:48 ` Sosnowski, Maciej
2009-04-14 8:41 ` [RFC][PATCH 0/6] IO pinning(get_user_pages()) vs fork race fix Nick Piggin
2009-04-14 9:19 ` KOSAKI Motohiro
2009-04-14 9:37 ` 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=20090415165431.AC4C.A69D9226@jp.fujitsu.com \
--to=kosaki.motohiro@jp.fujitsu.com \
--cc=aarcange@redhat.com \
--cc=akpm@osdl.org \
--cc=hugh@veritas.com \
--cc=jmoyer@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nickpiggin@yahoo.com.au \
--cc=torvalds@osdl.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