From: Lee Schermerhorn <lee.schermerhorn@hp.com>
To: linux-numa@vger.kernel.org
Cc: akpm@linux-foundation.org, Mel Gorman <mel@csn.ul.ie>,
cl@linux-foundation.org, Nick Piggin <npiggin@kernel.dk>,
Hugh Dickins <hughd@google.com>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
andi@firstfloor.org, David Rientjes <rientjes@google.com>,
Avi Kivity <avi@redhat.com>,
Andrea Arcangeli <aarcange@redhat.com>
Subject: [PATCH/RFC 5/8] numa - Migrate-on-Fault - migrate misplaced anon pages
Date: Thu, 11 Nov 2010 14:45:30 -0500 [thread overview]
Message-ID: <20101111194530.12535.14496.sendpatchset@zaphod.localdomain> (raw)
In-Reply-To: <20101111194450.12535.12611.sendpatchset@zaphod.localdomain>
Migrate-on-fault - handle misplaced anon pages
This patch simply hooks the anon page fault handler [do_swap_page()]
to check for and migrate misplaced pages if enabled and page won't
be "COWed".
Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp.com>
mm/memory.c | 27 +++++++++++++++++++++++++++
mm/shmem.c | 10 ++++++++++
mm/swapfile.c | 9 +++++++++
3 files changed, 46 insertions(+)
Index: linux-2.6.36-mmotm-101103-1217/mm/memory.c
===================================================================
--- linux-2.6.36-mmotm-101103-1217.orig/mm/memory.c
+++ linux-2.6.36-mmotm-101103-1217/mm/memory.c
@@ -57,6 +57,7 @@
#include <linux/swapops.h>
#include <linux/elf.h>
#include <linux/gfp.h>
+#include <linux/mempolicy.h> /* check_migrate_misplaced_page() */
#include <asm/io.h>
#include <asm/pgalloc.h>
@@ -2632,6 +2633,7 @@ static int do_swap_page(struct mm_struct
struct mem_cgroup *ptr = NULL;
int exclusive = 0;
int ret = 0;
+ int can_reuse;
if (!pte_unmap_same(mm, pmd, page_table, orig_pte))
goto out;
@@ -2716,6 +2718,31 @@ static int do_swap_page(struct mm_struct
}
/*
+ * No sense in migrating a page that will be "COWed" as the new
+ * new page will be allocated according to effective mempolicy.
+ */
+ can_reuse = (flags & FAULT_FLAG_WRITE) && reuse_swap_page(page);
+ if (can_reuse && migrate_on_fault_enabled(current)) {
+ if (!PageSwapCache(page)) {
+ /*
+ * migrate-on-fault has occurred - retry access
+ */
+ mem_cgroup_cancel_charge_swapin(ptr);
+ goto out_page;
+ }
+
+ /*
+ * check for misplacement and migrate, if necessary/possible,
+ * here and now. Note that if we're racing with another thread,
+ * we may end up discarding the migrated page after locking
+ * the page table and checking the pte below. However, we
+ * don't want to hold the page table locked over migration, so
+ * we'll live with that [unlikely, one hopes] possibility.
+ */
+ page = check_migrate_misplaced_page(page, vma, address);
+ }
+
+ /*
* Back out if somebody else already faulted in this pte.
*/
page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
Index: linux-2.6.36-mmotm-101103-1217/mm/swapfile.c
===================================================================
--- linux-2.6.36-mmotm-101103-1217.orig/mm/swapfile.c
+++ linux-2.6.36-mmotm-101103-1217/mm/swapfile.c
@@ -1143,6 +1143,7 @@ static int try_to_unuse(unsigned int typ
*/
swap_map = &si->swap_map[i];
entry = swp_entry(type, i);
+ again:
pol = get_vma_policy(current, NULL, 0);
page = read_swap_cache_async(entry, GFP_HIGHUSER_MOVABLE,
pol, i);
@@ -1179,6 +1180,14 @@ static int try_to_unuse(unsigned int typ
wait_on_page_locked(page);
wait_on_page_writeback(page);
lock_page(page);
+ if (!PageSwapCache(page)) {
+ /*
+ * Lazy page migration has occurred
+ */
+ unlock_page(page);
+ page_cache_release(page);
+ goto again;
+ }
wait_on_page_writeback(page);
/*
Index: linux-2.6.36-mmotm-101103-1217/mm/shmem.c
===================================================================
--- linux-2.6.36-mmotm-101103-1217.orig/mm/shmem.c
+++ linux-2.6.36-mmotm-101103-1217/mm/shmem.c
@@ -1304,6 +1304,16 @@ repeat:
page_cache_release(swappage);
goto repeat;
}
+ if (!PageSwapCache(swappage)) {
+ /*
+ * Lazy page migration has occurred
+ */
+ shmem_swp_unmap(entry);
+ spin_unlock(&info->lock);
+ unlock_page(swappage);
+ page_cache_release(swappage);
+ goto repeat;
+ }
if (PageWriteback(swappage)) {
shmem_swp_unmap(entry);
spin_unlock(&info->lock);
next prev parent reply other threads:[~2010-11-11 19:45 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-11 19:44 [PATCH/RFC 0/8] numa - Migrate-on-Fault Lee Schermerhorn
2010-11-11 19:44 ` [PATCH/RFC 1/8] numa - Migrate-on-Fault - add Kconfig option Lee Schermerhorn
2010-11-11 19:45 ` [PATCH/RFC 2/8] numa - Migrate-on-Fault - add cpuset control Lee Schermerhorn
2010-11-11 19:45 ` [PATCH/RFC 3/8] numa - Migrate-on-Fault - check for misplaced page Lee Schermerhorn
2010-11-11 19:45 ` [PATCH/RFC 4/8] numa - Migrate-on-Fault - migrate misplaced pages Lee Schermerhorn
2010-11-11 19:45 ` Lee Schermerhorn [this message]
2010-11-11 19:45 ` [PATCH/RFC 6/8] numa - Migrate-on-Fault - add mbind() MPOL_MF_LAZY flag Lee Schermerhorn
2010-11-11 19:45 ` [PATCH/RFC 7/8] numa - Migrate-on-Fault - mbind() NOOP policy Lee Schermerhorn
2010-11-11 19:45 ` [PATCH/RFC 8/8] numa - Migrate-on-Fault - add statistics Lee Schermerhorn
2010-11-14 6:37 ` [PATCH/RFC 0/8] numa - Migrate-on-Fault KOSAKI Motohiro
2010-11-15 14:13 ` Christoph Lameter
2010-11-15 14:21 ` Andi Kleen
2010-11-15 14:37 ` Andrea Arcangeli
2010-11-15 14:33 ` Andrea Arcangeli
2010-11-17 17:03 ` Lee Schermerhorn
2010-11-17 21:27 ` Andrea Arcangeli
2010-11-16 4:54 ` KOSAKI Motohiro
2010-11-17 14:45 ` Lee Schermerhorn
2010-11-17 17:10 ` Avi Kivity
2010-11-17 17:34 ` 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=20101111194530.12535.14496.sendpatchset@zaphod.localdomain \
--to=lee.schermerhorn@hp.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=avi@redhat.com \
--cc=cl@linux-foundation.org \
--cc=hughd@google.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-numa@vger.kernel.org \
--cc=mel@csn.ul.ie \
--cc=npiggin@kernel.dk \
--cc=rientjes@google.com \
/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).