From: Minchan Kim <minchan@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org, k.kozlowski@samsung.com,
Seth Jennings <sjenning@linux.vnet.ibm.com>,
Mel Gorman <mgorman@suse.de>,
guz.fnst@cn.fujitsu.com, Benjamin LaHaise <bcrl@kvack.org>,
Dave Hansen <dave.hansen@intel.com>,
lliubbo@gmail.com, aquini@redhat.com,
Rik van Riel <riel@redhat.com>, Minchan Kim <minchan@kernel.org>
Subject: [RFC 3/3] mm: migrate pinned page
Date: Tue, 13 Aug 2013 16:05:02 +0900 [thread overview]
Message-ID: <1376377502-28207-4-git-send-email-minchan@kernel.org> (raw)
In-Reply-To: <1376377502-28207-1-git-send-email-minchan@kernel.org>
Signed-off-by: Minchan Kim <minchan@kernel.org>
---
mm/compaction.c | 26 +++++++++++++++++++++++--
mm/migrate.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++-------
2 files changed, 75 insertions(+), 9 deletions(-)
diff --git a/mm/compaction.c b/mm/compaction.c
index 05ccb4c..16b80e6 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -396,8 +396,10 @@ static void acct_isolated(struct zone *zone, bool locked, struct compact_control
struct page *page;
unsigned int count[2] = { 0, };
- list_for_each_entry(page, &cc->migratepages, lru)
- count[!!page_is_file_cache(page)]++;
+ list_for_each_entry(page, &cc->migratepages, lru) {
+ if (!PagePin(page))
+ count[!!page_is_file_cache(page)]++;
+ }
/* If locked we can use the interrupt unsafe versions */
if (locked) {
@@ -535,6 +537,25 @@ isolate_migratepages_range(struct zone *zone, struct compact_control *cc,
}
/*
+ * Pinned kernel page(ex, zswap) could be isolated.
+ */
+ if (PagePin(page)) {
+ if (!get_page_unless_zero(page))
+ continue;
+ /*
+ * Subsystem want to use pinpage should not
+ * use page->lru feild.
+ */
+ VM_BUG_ON(!list_empty(&page->lru));
+ if (!trylock_page(page)) {
+ put_page(page);
+ continue;
+ }
+
+ goto isolated;
+ }
+
+ /*
* Check may be lockless but that's ok as we recheck later.
* It's possible to migrate LRU pages and balloon pages
* Skip any other type of page
@@ -601,6 +622,7 @@ isolate_migratepages_range(struct zone *zone, struct compact_control *cc,
/* Successfully isolated */
cc->finished_update_migrate = true;
del_page_from_lru_list(page, lruvec, page_lru(page));
+isolated:
list_add(&page->lru, migratelist);
cc->nr_migratepages++;
nr_isolated++;
diff --git a/mm/migrate.c b/mm/migrate.c
index 6f0c244..4d28049 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -36,6 +36,7 @@
#include <linux/hugetlb_cgroup.h>
#include <linux/gfp.h>
#include <linux/balloon_compaction.h>
+#include <linux/pinpage.h>
#include <asm/tlbflush.h>
@@ -101,12 +102,17 @@ void putback_movable_pages(struct list_head *l)
list_for_each_entry_safe(page, page2, l, lru) {
list_del(&page->lru);
- dec_zone_page_state(page, NR_ISOLATED_ANON +
- page_is_file_cache(page));
- if (unlikely(balloon_page_movable(page)))
- balloon_page_putback(page);
- else
- putback_lru_page(page);
+ if (!PagePin(page)) {
+ dec_zone_page_state(page, NR_ISOLATED_ANON +
+ page_is_file_cache(page));
+ if (unlikely(balloon_page_movable(page)))
+ balloon_page_putback(page);
+ else
+ putback_lru_page(page);
+ } else {
+ unlock_page(page);
+ put_page(page);
+ }
}
}
@@ -855,6 +861,39 @@ out:
return rc;
}
+static int unmap_and_move_pinpage(new_page_t get_new_page,
+ unsigned long private, struct page *page, int force,
+ enum migrate_mode mode)
+{
+ int *result = NULL;
+ int rc = 0;
+ struct page *newpage = get_new_page(page, private, &result);
+ if (!newpage)
+ return -ENOMEM;
+
+ VM_BUG_ON(!PageLocked(page));
+ if (page_count(page) == 1) {
+ /* page was freed from under us. So we are done. */
+ goto out;
+ }
+
+ rc = migrate_pinpage(page, newpage);
+out:
+ if (rc != -EAGAIN) {
+ list_del(&page->lru);
+ unlock_page(page);
+ put_page(page);
+ }
+
+ if (result) {
+ if (rc)
+ *result = rc;
+ else
+ *result = page_to_nid(newpage);
+ }
+ return rc;
+
+}
/*
* Obtain the lock on page, remove all ptes and migrate the page
* to the newly allocated page in newpage.
@@ -1025,8 +1064,13 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
list_for_each_entry_safe(page, page2, from, lru) {
cond_resched();
- rc = unmap_and_move(get_new_page, private,
+ if (PagePin(page)) {
+ rc = unmap_and_move_pinpage(get_new_page, private,
page, pass > 2, mode);
+ } else {
+ rc = unmap_and_move(get_new_page, private,
+ page, pass > 2, mode);
+ }
switch(rc) {
case -ENOMEM:
--
1.7.9.5
--
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:[~2013-08-13 7:05 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-13 7:04 [RFC 0/3] Pin page control subsystem Minchan Kim
2013-08-13 7:05 ` [RFC 1/3] mm: Introduce new page flag Minchan Kim
2013-08-13 7:05 ` [RFC 2/3] pinpage control subsystem Minchan Kim
2013-08-13 7:05 ` Minchan Kim [this message]
2013-08-13 9:46 ` [RFC 0/3] Pin page " Krzysztof Kozlowski
2013-08-13 14:23 ` Benjamin LaHaise
2013-08-14 0:08 ` Minchan Kim
2013-08-13 23:54 ` Minchan Kim
2013-08-13 16:21 ` Christoph Lameter
2013-08-14 0:12 ` Minchan Kim
2013-08-14 16:36 ` Christoph Lameter
2013-08-14 16:47 ` Minchan Kim
2013-08-14 16:58 ` Christoph Lameter
2013-08-15 4:48 ` Minchan Kim
2013-08-15 15:18 ` Christoph Lameter
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=1376377502-28207-4-git-send-email-minchan@kernel.org \
--to=minchan@kernel.org \
--cc=aquini@redhat.com \
--cc=bcrl@kvack.org \
--cc=dave.hansen@intel.com \
--cc=guz.fnst@cn.fujitsu.com \
--cc=k.kozlowski@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lliubbo@gmail.com \
--cc=mgorman@suse.de \
--cc=riel@redhat.com \
--cc=sjenning@linux.vnet.ibm.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).