From: Christoph Lameter <clameter@sgi.com>
To: Andrew Morton <akpm@osdl.org>
Cc: hugh@veritas.com, linux-kernel@vger.kernel.org,
lee.schermerhorn@hp.com, linux-mm@kvack.org, taka@valinux.co.jp,
marcelo.tosatti@cyclades.com, kamezawa.hiroyu@jp.fujitsu.com
Subject: migration_entry_wait: Use the pte lock instead of the anon_vma lock.
Date: Mon, 17 Apr 2006 16:52:13 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.64.0604171649570.31773@schroedinger.engr.sgi.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0604141417170.22852@schroedinger.engr.sgi.com>
Use of the pte lock allows for much finer grained locking and avoids
the complexity coming with locking via the anon_vma. It will also
make the fetching of the pte value cleaner. Add a couple of other
improvements as well.
Signed-off-by: Christoph Lameter <clameter@sgi.com>
Index: linux-2.6.17-rc1-mm2/mm/memory.c
===================================================================
--- linux-2.6.17-rc1-mm2.orig/mm/memory.c 2006-04-14 14:47:37.000000000 -0700
+++ linux-2.6.17-rc1-mm2/mm/memory.c 2006-04-17 16:23:50.000000000 -0700
@@ -1881,7 +1881,7 @@ static int do_swap_page(struct mm_struct
entry = pte_to_swp_entry(orig_pte);
if (is_migration_entry(entry)) {
- migration_entry_wait(entry, page_table);
+ migration_entry_wait(mm, pmd, address);
goto out;
}
Index: linux-2.6.17-rc1-mm2/include/linux/swapops.h
===================================================================
--- linux-2.6.17-rc1-mm2.orig/include/linux/swapops.h 2006-04-14 14:47:37.000000000 -0700
+++ linux-2.6.17-rc1-mm2/include/linux/swapops.h 2006-04-17 16:45:52.000000000 -0700
@@ -91,13 +91,15 @@ static inline struct page *migration_ent
return p;
}
-extern void migration_entry_wait(swp_entry_t entry, pte_t *);
+extern void migration_entry_wait(struct mm_struct *mm, pmd_t *pmd,
+ unsigned long address);
#else
#define make_migration_entry(page) swp_entry(0, 0)
#define is_migration_entry(swp) 0
#define migration_entry_to_page(swp) NULL
-static inline void migration_entry_wait(swp_entry_t entry, pte_t *ptep) { }
+static inline void migration_entry_wait(struct mm_struct *mm, pmd_t *pmd,
+ unsigned long address) { }
#endif
Index: linux-2.6.17-rc1-mm2/mm/migrate.c
===================================================================
--- linux-2.6.17-rc1-mm2.orig/mm/migrate.c 2006-04-14 14:47:37.000000000 -0700
+++ linux-2.6.17-rc1-mm2/mm/migrate.c 2006-04-17 16:46:45.000000000 -0700
@@ -180,48 +180,35 @@ out:
*
* This function is called from do_swap_page().
*/
-void migration_entry_wait(swp_entry_t entry, pte_t *ptep)
+void migration_entry_wait(struct mm_struct *mm, pmd_t *pmd,
+ unsigned long address)
{
- struct page *page = migration_entry_to_page(entry);
- unsigned long mapping = (unsigned long)page->mapping;
- struct anon_vma *anon_vma;
- pte_t pte;
-
- if (!mapping ||
- (mapping & PAGE_MAPPING_ANON) == 0)
- return;
- /*
- * We hold the mmap_sem lock.
- */
- anon_vma = (struct anon_vma *) (mapping - PAGE_MAPPING_ANON);
+ pte_t *ptep, pte;
+ spinlock_t *ptl;
+ swp_entry_t entry;
+ struct page *page;
- /*
- * The anon_vma lock is also taken while removing the migration
- * entries. Take the lock here to insure that the migration pte
- * is not modified while we increment the page count.
- * This is similar to find_get_page().
- */
- spin_lock(&anon_vma->lock);
+ ptep = pte_offset_map_lock(mm, pmd, address, &ptl);
pte = *ptep;
- if (pte_present(pte) || pte_none(pte) || pte_file(pte)) {
- spin_unlock(&anon_vma->lock);
- return;
- }
+ if (!is_swap_pte(pte))
+ goto out;
+
entry = pte_to_swp_entry(pte);
- if (!is_migration_entry(entry) ||
- migration_entry_to_page(entry) != page) {
- /* Migration entry is gone */
- spin_unlock(&anon_vma->lock);
- return;
- }
- /* Pages with migration entries must be locked */
+ if (!is_migration_entry(entry))
+ goto out;
+
+ page = migration_entry_to_page(entry);
+
+ /* Pages with migration entries are always locked */
BUG_ON(!PageLocked(page));
- /* Phew. Finally we can increment the refcount */
get_page(page);
- spin_unlock(&anon_vma->lock);
+ pte_unmap_unlock(ptep, ptl);
wait_on_page_locked(page);
put_page(page);
+ return;
+out:
+ pte_unmap_unlock(ptep, ptl);
}
/*
--
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-17 23:52 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 ` Christoph Lameter [this message]
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
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=Pine.LNX.4.64.0604171649570.31773@schroedinger.engr.sgi.com \
--to=clameter@sgi.com \
--cc=akpm@osdl.org \
--cc=hugh@veritas.com \
--cc=kamezawa.hiroyu@jp.fujitsu.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;
as well as URLs for NNTP newsgroup(s).