aboutsummaryrefslogtreecommitdiffstats
path: root/mm/migrate.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/migrate.c')
-rw-r--r--mm/migrate.c75
1 files changed, 3 insertions, 72 deletions
diff --git a/mm/migrate.c b/mm/migrate.c
index 0a011e421bb4..81721a061d50 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -70,10 +70,6 @@ int isolate_lru_page(struct page *page, struct list_head *pagelist)
70 */ 70 */
71int migrate_prep(void) 71int migrate_prep(void)
72{ 72{
73 /* Must have swap device for migration */
74 if (nr_swap_pages <= 0)
75 return -ENODEV;
76
77 /* 73 /*
78 * Clear the LRU lists so pages can be isolated. 74 * Clear the LRU lists so pages can be isolated.
79 * Note that pages may be moved off the LRU after we have 75 * Note that pages may be moved off the LRU after we have
@@ -246,52 +242,6 @@ out:
246} 242}
247 243
248/* 244/*
249 * swapout a single page
250 * page is locked upon entry, unlocked on exit
251 */
252static int swap_page(struct page *page)
253{
254 struct address_space *mapping = page_mapping(page);
255
256 if (page_mapped(page) && mapping)
257 if (try_to_unmap(page, 1) != SWAP_SUCCESS)
258 goto unlock_retry;
259
260 if (PageDirty(page)) {
261 /* Page is dirty, try to write it out here */
262 switch(pageout(page, mapping)) {
263 case PAGE_KEEP:
264 case PAGE_ACTIVATE:
265 goto unlock_retry;
266
267 case PAGE_SUCCESS:
268 goto retry;
269
270 case PAGE_CLEAN:
271 ; /* try to free the page below */
272 }
273 }
274
275 if (PagePrivate(page)) {
276 if (!try_to_release_page(page, GFP_KERNEL) ||
277 (!mapping && page_count(page) == 1))
278 goto unlock_retry;
279 }
280
281 if (remove_mapping(mapping, page)) {
282 /* Success */
283 unlock_page(page);
284 return 0;
285 }
286
287unlock_retry:
288 unlock_page(page);
289
290retry:
291 return -EAGAIN;
292}
293
294/*
295 * Replace the page in the mapping. 245 * Replace the page in the mapping.
296 * 246 *
297 * The number of remaining references must be: 247 * The number of remaining references must be:
@@ -517,8 +467,7 @@ static int fallback_migrate_page(struct address_space *mapping,
517 * Two lists are passed to this function. The first list 467 * Two lists are passed to this function. The first list
518 * contains the pages isolated from the LRU to be migrated. 468 * contains the pages isolated from the LRU to be migrated.
519 * The second list contains new pages that the pages isolated 469 * The second list contains new pages that the pages isolated
520 * can be moved to. If the second list is NULL then all 470 * can be moved to.
521 * pages are swapped out.
522 * 471 *
523 * The function returns after 10 attempts or if no pages 472 * The function returns after 10 attempts or if no pages
524 * are movable anymore because to has become empty 473 * are movable anymore because to has become empty
@@ -574,29 +523,11 @@ redo:
574 * Only wait on writeback if we have already done a pass where 523 * Only wait on writeback if we have already done a pass where
575 * we we may have triggered writeouts for lots of pages. 524 * we we may have triggered writeouts for lots of pages.
576 */ 525 */
577 if (pass > 0) { 526 if (pass > 0)
578 wait_on_page_writeback(page); 527 wait_on_page_writeback(page);
579 } else { 528 else
580 if (PageWriteback(page)) 529 if (PageWriteback(page))
581 goto unlock_page; 530 goto unlock_page;
582 }
583
584 /*
585 * Anonymous pages must have swap cache references otherwise
586 * the information contained in the page maps cannot be
587 * preserved.
588 */
589 if (PageAnon(page) && !PageSwapCache(page)) {
590 if (!add_to_swap(page, GFP_KERNEL)) {
591 rc = -ENOMEM;
592 goto unlock_page;
593 }
594 }
595
596 if (!to) {
597 rc = swap_page(page);
598 goto next;
599 }
600 531
601 /* 532 /*
602 * Establish swap ptes for anonymous pages or destroy pte 533 * Establish swap ptes for anonymous pages or destroy pte