From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: Christoph Lameter <clameter@sgi.com>
Cc: akpm@osdl.org, hugh@veritas.com, linux-kernel@vger.kernel.org,
lee.schermerhorn@hp.com, linux-mm@kvack.org, taka@valinux.co.jp,
marcelo.tosatti@cyclades.com
Subject: Re: [PATCH 5/5] Swapless V2: Revise main migration logic
Date: Tue, 18 Apr 2006 18:08:10 +0900 [thread overview]
Message-ID: <20060418180810.e947564c.kamezawa.hiroyu@jp.fujitsu.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0604180126221.4627@schroedinger.engr.sgi.com>
On Tue, 18 Apr 2006 01:27:40 -0700 (PDT)
Christoph Lameter <clameter@sgi.com> wrote:
> On Tue, 18 Apr 2006, KAMEZAWA Hiroyuki wrote:
>
> > On Mon, 17 Apr 2006 23:58:41 -0700 (PDT)
> > Christoph Lameter <clameter@sgi.com> wrote:
> >
> > > Hmmm... Good ideas. I think it could be much simpler like the following
> > > patch.
> > >
> > > However, the problem here is how to know that we really took the anon_vma
> > > lock and what to do about a page being unmmapped while migrating. This
> > > could cause the anon_vma not to be unlocked.
> > >
> > lock dependency here is page_lock(page) -> page's anon_vma->lock.
> > So, I guess anon_vma->lock cannot be unlocked by other threads
> > if we have page_lock(page).
>
> No the problem is to know if the lock was really taken. SWAP_AGAIN could
> mean that page_lock_anon_vma failed.
>
Ah, I see. and understood what you did in http://lkml.org/lkml/2006/4/18/19
That will be happen when the migration takes the anon_vma->lock in
try_to_unmap().
> Also the page may be freed while it is being processes. In that case
> remove_migration_ptes may not find the mapping and may not unlock the
> anon_vma.
>
My patch in http://lkml.org/lkml/2006/4/17/180
This is a look when above patch is applied.
==
/*
* Common logic to directly migrate a single page suitable for
* pages that do not use PagePrivate.
*
* Pages are locked upon entry and exit.
*/
int migrate_page(struct page *newpage, struct page *page)
{
int rc;
struct anon_vma *anon_vma;
BUG_ON(PageWriteback(page)); /* Writeback must be complete */
if (PageAnon(page)) {
anon_vma = page_lock_anon_vma(page);
}
rc = migrate_page_remove_references(newpage, page,
page_mapping(page) ? 2 : 1);
if (rc) {
remove_migration_ptes(anon_vma, page, page);
goto unlock_out;
}
migrate_page_copy(newpage, page);
remove_migration_ptes(anon_vma, page, newpage);
unlock_out:
if (anon_vma)
spin_unlock(&anon_vma->lock);
return rc;
}
==
lock around anon_vma->lock does not depend on the result of
try_to_unmap() and remove_migration_ptes().
But I agree : 'taking anon_vma->lock before try_to_unmap() is ugly and complicated
and will make things insane.'
Will this attached one make things clearer ?
This anon_vma->lock is just an optimization (for now) but complicated.
I think restart discusstion against -mm3? will be better.
-Kame
==
Index: Christoph-NewMigrationV2/mm/rmap.c
===================================================================
--- Christoph-NewMigrationV2.orig/mm/rmap.c
+++ Christoph-NewMigrationV2/mm/rmap.c
@@ -711,29 +711,44 @@ static void try_to_unmap_cluster(unsigne
pte_unmap_unlock(pte - 1, ptl);
}
-static int try_to_unmap_anon(struct page *page, int migration)
+static int __try_to_unmap_anon(struct anon_vma *anon_vma,
+ struct page *page, int migration)
{
- struct anon_vma *anon_vma;
struct vm_area_struct *vma;
int ret = SWAP_AGAIN;
- if (migration) { /* anon_vma->lock is held under migration */
- unsigned long mapping;
- mapping = (unsigned long)page->mapping - PAGE_MAPPING_ANON;
- anon_vma = (struct anon_vma *)mapping;
- } else {
- anon_vma = page_lock_anon_vma(page);
- }
- if (!anon_vma)
- return ret;
-
list_for_each_entry(vma, &anon_vma->head, anon_vma_node) {
ret = try_to_unmap_one(page, vma, migration);
if (ret == SWAP_FAIL || !page_mapped(page))
break;
}
- if (!migration)
- spin_unlock(&anon_vma->lock);
+ return ret;
+}
+
+static int try_to_unmap_anon(struct page *page)
+{
+ struct anon_vma *anon_vma;
+ struct vm_area_struct *vma;
+ int ret = SWAP_AGAIN;
+
+ anon_vma = page_lock_anon_vma(page);
+ if (!anon_vma)
+ return ret;
+ ret = __try_to_unmap_anon(anon_vma, page, 0);
+ spin_unlock(&anon_vma->lock);
+ return ret;
+}
+
+static int try_to_unmap_anon_migrate(struct page *page)
+{
+ struct anon_vma *anon_vma;
+ unsigned long mapping;
+ int ret = SWAP_AGAIN;
+ if (PageAnon(page))
+ return ret;
+ mapping = page->mapping;
+ anon_vma = (struct anon_vma *)(mapping - PAGE_MAPPING_ANON);
+ ret = __try_to_unmap_anon_migrate(anon_vma, page, 1);
return ret;
}
@@ -851,9 +866,12 @@ int try_to_unmap(struct page *page, int
BUG_ON(!PageLocked(page));
- if (PageAnon(page))
- ret = try_to_unmap_anon(page, migration);
- else
+ if (PageAnon(page)) {
+ if (migration)
+ ret = try_to_unmap_anon_migrate(page);
+ else
+ ret = try_to_unmap_anon(page);
+ } else
ret = try_to_unmap_file(page, migration);
if (!page_mapped(page))
--
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:[~2006-04-18 9:08 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-13 23:54 [PATCH 0/5] Swapless page migration V2: Overview Christoph Lameter
2006-04-13 23:54 ` [PATCH 1/5] Swapless V2: try_to_unmap() - Rename ignrefs to "migration" Christoph Lameter
2006-04-13 23:54 ` [PATCH 2/5] Swapless V2: Add migration swap entries Christoph Lameter
2006-04-14 0:13 ` Andrew Morton
2006-04-14 0:29 ` Christoph Lameter
2006-04-14 0:42 ` Andrew Morton
2006-04-14 0:46 ` Christoph Lameter
2006-04-14 1:01 ` Andrew Morton
2006-04-14 1:17 ` Andrew Morton
2006-04-14 1:31 ` Christoph Lameter
2006-04-14 5:25 ` Andrew Morton
2006-04-14 14:27 ` Lee Schermerhorn
2006-04-14 16:01 ` Christoph Lameter
2006-04-14 1:31 ` Christoph Lameter
2006-04-14 5:29 ` Andrew Morton
2006-04-14 17:28 ` Implement lookup_swap_cache for migration entries Christoph Lameter
2006-04-14 18:31 ` Andrew Morton
2006-04-14 18:48 ` Christoph Lameter
2006-04-14 19:15 ` Andrew Morton
2006-04-14 19:22 ` Christoph Lameter
2006-04-14 19:53 ` Andrew Morton
2006-04-14 20:12 ` Christoph Lameter
2006-04-14 21:51 ` Wait for migrating page after incr of page count under anon_vma lock Christoph Lameter
2006-04-17 23:52 ` migration_entry_wait: Use the pte lock instead of the " Christoph Lameter
2006-04-14 0:36 ` [PATCH 2/5] Swapless V2: Add migration swap entries Christoph Lameter
2006-04-13 23:54 ` [PATCH 3/5] Swapless V2: Make try_to_unmap() create migration entries Christoph Lameter
2006-04-13 23:54 ` [PATCH 4/5] Swapless V2: Rip out swap portion of old migration code Christoph Lameter
2006-04-13 23:54 ` [PATCH 5/5] Swapless V2: Revise main migration logic Christoph Lameter
2006-04-14 1:19 ` KAMEZAWA Hiroyuki
2006-04-14 1:33 ` Christoph Lameter
2006-04-14 1:40 ` KAMEZAWA Hiroyuki
2006-04-14 2:34 ` KAMEZAWA Hiroyuki
2006-04-14 2:44 ` KAMEZAWA Hiroyuki
2006-04-14 17:29 ` Preserve write permissions in migration entries Christoph Lameter
2006-04-14 16:48 ` [PATCH 5/5] Swapless V2: Revise main migration logic Christoph Lameter
2006-04-15 0:06 ` KAMEZAWA Hiroyuki
2006-04-15 17:41 ` Christoph Lameter
2006-04-17 0:18 ` KAMEZAWA Hiroyuki
2006-04-17 17:00 ` Christoph Lameter
2006-04-18 0:04 ` KAMEZAWA Hiroyuki
2006-04-18 0:27 ` Christoph Lameter
2006-04-18 0:42 ` KAMEZAWA Hiroyuki
2006-04-18 1:57 ` Christoph Lameter
2006-04-18 3:00 ` KAMEZAWA Hiroyuki
2006-04-18 3:16 ` Christoph Lameter
2006-04-18 3:32 ` KAMEZAWA Hiroyuki
2006-04-18 6:58 ` Christoph Lameter
2006-04-18 8:05 ` KAMEZAWA Hiroyuki
2006-04-18 8:27 ` Christoph Lameter
2006-04-18 9:08 ` KAMEZAWA Hiroyuki [this message]
2006-04-18 16:49 ` Christoph Lameter
2006-04-14 0:08 ` [PATCH 0/5] Swapless page migration V2: Overview Andrew Morton
2006-04-14 0:27 ` Christoph Lameter
2006-04-14 14:14 ` Lee Schermerhorn
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=20060418180810.e947564c.kamezawa.hiroyu@jp.fujitsu.com \
--to=kamezawa.hiroyu@jp.fujitsu.com \
--cc=akpm@osdl.org \
--cc=clameter@sgi.com \
--cc=hugh@veritas.com \
--cc=lee.schermerhorn@hp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=marcelo.tosatti@cyclades.com \
--cc=taka@valinux.co.jp \
/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