Skip to content

Commit 7cbe34c

Browse files
Christoph LameterLinus Torvalds
authored andcommitted
[PATCH] Swap Migration V5: Add CONFIG_MIGRATION for page migration support
Include page migration if the system is NUMA or having a memory model that allows distinct areas of memory (SPARSEMEM, DISCONTIGMEM). And: - Only include lru_add_drain_per_cpu if building for an SMP system. Signed-off-by: Christoph Lameter <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 49d2e9c commit 7cbe34c

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

include/linux/swap.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ extern int vm_swappiness;
178178
extern int isolate_lru_page(struct page *p);
179179
extern int putback_lru_pages(struct list_head *l);
180180

181+
#ifdef CONFIG_MIGRATION
181182
extern int migrate_pages(struct list_head *l, struct list_head *t);
183+
#endif
182184

183185
#ifdef CONFIG_MMU
184186
/* linux/mm/shmem.c */

mm/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,10 @@ config SPLIT_PTLOCK_CPUS
132132
default "4096" if ARM && !CPU_CACHE_VIPT
133133
default "4096" if PARISC && !PA20
134134
default "4"
135+
136+
#
137+
# support for page migration
138+
#
139+
config MIGRATION
140+
def_bool y if NUMA || SPARSEMEM || DISCONTIGMEM
141+
depends on SWAP

mm/vmscan.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ static int shrink_list(struct list_head *page_list, struct scan_control *sc)
568568
return reclaimed;
569569
}
570570

571+
#ifdef CONFIG_MIGRATION
571572
/*
572573
* swapout a single page
573574
* page is locked upon entry, unlocked on exit
@@ -656,8 +657,9 @@ int migrate_pages(struct list_head *l, struct list_head *t)
656657

657658
/*
658659
* Skip locked pages during the first two passes to give the
659-
* functions holding the lock time to release the page. Later we use
660-
* lock_page to have a higher chance of acquiring the lock.
660+
* functions holding the lock time to release the page. Later we
661+
* use lock_page() to have a higher chance of acquiring the
662+
* lock.
661663
*/
662664
if (pass > 2)
663665
lock_page(page);
@@ -669,15 +671,15 @@ int migrate_pages(struct list_head *l, struct list_head *t)
669671
* Only wait on writeback if we have already done a pass where
670672
* we we may have triggered writeouts for lots of pages.
671673
*/
672-
if (pass > 0)
674+
if (pass > 0) {
673675
wait_on_page_writeback(page);
674-
else
676+
} else {
675677
if (PageWriteback(page)) {
676678
unlock_page(page);
677679
goto retry_later;
678680
}
681+
}
679682

680-
#ifdef CONFIG_SWAP
681683
if (PageAnon(page) && !PageSwapCache(page)) {
682684
if (!add_to_swap(page)) {
683685
unlock_page(page);
@@ -686,16 +688,15 @@ int migrate_pages(struct list_head *l, struct list_head *t)
686688
continue;
687689
}
688690
}
689-
#endif /* CONFIG_SWAP */
690691

691692
/*
692693
* Page is properly locked and writeback is complete.
693694
* Try to migrate the page.
694695
*/
695-
if (swap_page(page)) {
696+
if (!swap_page(page))
697+
continue;
696698
retry_later:
697-
retry++;
698-
}
699+
retry++;
699700
}
700701
if (retry && pass++ < 10)
701702
goto redo;
@@ -708,6 +709,7 @@ int migrate_pages(struct list_head *l, struct list_head *t)
708709

709710
return nr_failed + retry;
710711
}
712+
#endif
711713

712714
/*
713715
* zone->lru_lock is heavily contended. Some of the functions that

0 commit comments

Comments
 (0)