From: Konstantin Khlebnikov <koct9i@gmail.com>
To: linux-mm@kvack.org
Subject: [PATCH RFC v0 6/6] mm/migrate: preserve lru order if possible
Date: Mon, 15 Jun 2015 10:51:11 +0300 [thread overview]
Message-ID: <20150615075111.18112.88400.stgit@zurg> (raw)
In-Reply-To: <20150615073926.18112.59207.stgit@zurg>
TODO
* link old and new pages and insert them as a batch later
Signed-off-by: Konstantin Khlebnikov <koct9i@gmail.com>
---
mm/internal.h | 1 +
mm/migrate.c | 7 +++++--
mm/swap.c | 25 +++++++++++++++++++++++++
3 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/mm/internal.h b/mm/internal.h
index 19081ba..6184fc2 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -99,6 +99,7 @@ extern unsigned long highest_memmap_pfn;
*/
extern int isolate_lru_page(struct page *page);
extern void putback_lru_page(struct page *page);
+extern void insert_lru_page(struct page *page, struct page *pos);
extern bool zone_reclaimable(struct zone *zone);
/*
diff --git a/mm/migrate.c b/mm/migrate.c
index c060991..e171981 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -947,10 +947,13 @@ out:
if (rc != MIGRATEPAGE_SUCCESS && put_new_page) {
ClearPageSwapBacked(newpage);
put_new_page(newpage, private);
- } else if (unlikely(__is_movable_balloon_page(newpage))) {
+ } else if (rc != MIGRATEPAGE_SUCCESS ||
+ unlikely(__is_movable_balloon_page(newpage))) {
/* drop our reference, page already in the balloon */
put_page(newpage);
- } else
+ } else if (PageLRU(page))
+ insert_lru_page(newpage, page);
+ else
putback_lru_page(newpage);
if (result) {
diff --git a/mm/swap.c b/mm/swap.c
index 3ec0eb5..40559d6 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -518,6 +518,31 @@ static void __activate_page(struct page *page, struct lruvec *lruvec,
}
}
+void insert_lru_page(struct page *page, struct page *pos)
+{
+ struct zone *zone = page_zone(page);
+ int lru = page_lru_base_type(page);
+ struct lruvec *lruvec;
+ unsigned long flags;
+
+ if (page_evictable(page) && lru == page_lru(pos) &&
+#ifdef CONFIG_MEMCG
+ page->mem_cgroup == pos->mem_cgroup &&
+#endif
+ zone == page_zone(pos)) {
+ spin_lock_irqsave(&zone->lru_lock, flags);
+ lruvec = mem_cgroup_page_lruvec(page, zone);
+ SetPageLRU(page);
+ add_page_to_lru_list(page, lruvec, lru);
+ trace_mm_lru_insertion(page, lru);
+ if (PageLRU(pos) &&
+ lruvec == mem_cgroup_page_lruvec(pos, zone))
+ list_move(&page->lru, &pos->lru);
+ spin_unlock_irqrestore(&zone->lru_lock, flags);
+ } else
+ putback_lru_page(page);
+}
+
#ifdef CONFIG_SMP
static DEFINE_PER_CPU(struct pagevec, activate_page_pvecs);
--
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:[~2015-06-15 7:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-15 7:50 [PATCH RFC v0 0/6] mm: proof-of-concept memory compaction without isolation Konstantin Khlebnikov
2015-06-15 7:51 ` [PATCH RFC v0 1/6] pagevec: segmented page vectors Konstantin Khlebnikov
2015-06-15 7:51 ` [PATCH RFC v0 2/6] mm/migrate: move putback of old page out of unmap_and_move Konstantin Khlebnikov
2015-06-15 7:51 ` [PATCH RFC v0 3/6] mm/cma: repalce reclaim_clean_pages_from_list with try_to_reclaim_page Konstantin Khlebnikov
2015-06-15 7:51 ` [PATCH RFC v0 4/6] mm/migrate: page migration without page isolation Konstantin Khlebnikov
2015-06-15 7:51 ` [PATCH RFC v0 5/6] mm/compaction: use migration without isolation Konstantin Khlebnikov
2015-06-15 7:51 ` Konstantin Khlebnikov [this message]
2015-06-15 9:52 ` [PATCH RFC v0 0/6] mm: proof-of-concept memory compaction " Vlastimil Babka
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=20150615075111.18112.88400.stgit@zurg \
--to=koct9i@gmail.com \
--cc=linux-mm@kvack.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.