TODO * link old and new pages and insert them as a batch later Signed-off-by: Konstantin Khlebnikov <koct9i@xxxxxxxxx> --- 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@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>