[PATCH] SwapMig: Switch error handling in migrate_pages to use -Exx
From: Christoph Lameter
Date: Fri Nov 18 2005 - 15:04:55 EST
Use -Exxx instead of numeric return codes and cleanup the code
in migrate_pages() using -Exx error codes.
Signed-off-by: Christoph Lameter <clameter@xxxxxxx>
Index: linux-2.6.15-rc1-mm2/mm/vmscan.c
===================================================================
--- linux-2.6.15-rc1-mm2.orig/mm/vmscan.c 2005-11-18 10:04:05.000000000 -0800
+++ linux-2.6.15-rc1-mm2/mm/vmscan.c 2005-11-18 10:12:01.000000000 -0800
@@ -608,10 +608,6 @@ int putback_lru_pages(struct list_head *
/*
* swapout a single page
* page is locked upon entry, unlocked on exit
- *
- * return codes:
- * 0 = complete
- * 1 = retry
*/
static int swap_page(struct page *page)
{
@@ -652,7 +648,7 @@ unlock_retry:
unlock_page(page);
retry:
- return 1;
+ return -EAGAIN;
}
/*
* migrate_pages
@@ -671,6 +667,8 @@ retry:
* is only swapping out pages and never touches the second
* list. The direct migration patchset
* extends this function to avoid the use of swap.
+ *
+ * Return: Number of pages not migrated when "to" ran empty.
*/
int migrate_pages(struct list_head *from, struct list_head *to,
struct list_head *moved, struct list_head *failed)
@@ -681,6 +679,7 @@ int migrate_pages(struct list_head *from
struct page *page;
struct page *page2;
int swapwrite = current->flags & PF_SWAPWRITE;
+ int rc;
if (!swapwrite)
current->flags |= PF_SWAPWRITE;
@@ -702,11 +701,12 @@ redo:
* use lock_page() to have a higher chance of acquiring the
* lock.
*/
+ rc = -EAGAIN;
if (pass > 2)
lock_page(page);
else
if (TestSetPageLocked(page))
- goto retry_later;
+ goto next;
/*
* Only wait on writeback if we have already done a pass where
@@ -715,18 +715,19 @@ redo:
if (pass > 0) {
wait_on_page_writeback(page);
} else {
- if (PageWriteback(page)) {
- unlock_page(page);
- goto retry_later;
- }
+ if (PageWriteback(page))
+ goto unlock_page;
}
+ /*
+ * Anonymous pages must have swap cache references otherwise
+ * the information contained in the page maps cannot be
+ * preserved.
+ */
if (PageAnon(page) && !PageSwapCache(page)) {
if (!add_to_swap(page, GFP_KERNEL)) {
- unlock_page(page);
- list_move(&page->lru, failed);
- nr_failed++;
- continue;
+ rc = -ENOMEM;
+ goto unlock_page;
}
}
@@ -738,8 +739,19 @@ redo:
list_move(&page->lru, moved);
continue;
}
-retry_later:
- retry++;
+
+unlock_page:
+ unlock_page(page);
+
+next:
+ if (rc == -EAGAIN)
+ retry++;
+
+ else if (rc) {
+ /* Permanent failure to migrate the page */
+ list_move(&page->lru, failed);
+ nr_failed++;
+ }
}
if (retry && pass++ < 10)
goto redo;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/