[PATCH RFC v0 2/6] mm/migrate: move putback of old page out of unmap_and_move

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is preparation for migrating non-isolated pages.

Signed-off-by: Konstantin Khlebnikov <koct9i@xxxxxxxxx>
---
 mm/migrate.c |   34 ++++++++++++++--------------------
 1 file changed, 14 insertions(+), 20 deletions(-)

diff --git a/mm/migrate.c b/mm/migrate.c
index f53838f..eca80b3 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -939,19 +939,6 @@ static ICE_noinline int unmap_and_move(new_page_t get_new_page,
 	rc = __unmap_and_move(page, newpage, force, mode);
 
 out:
-	if (rc != -EAGAIN) {
-		/*
-		 * A page that has been migrated has all references
-		 * removed and will be freed. A page that has not been
-		 * migrated will have kepts its references and be
-		 * restored.
-		 */
-		list_del(&page->lru);
-		dec_zone_page_state(page, NR_ISOLATED_ANON +
-				page_is_file_cache(page));
-		putback_lru_page(page);
-	}
-
 	/*
 	 * If migration was not successful and there's a freeing callback, use
 	 * it.  Otherwise, putback_lru_page() will drop the reference grabbed
@@ -1011,10 +998,8 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
 	 * tables or check whether the hugepage is pmd-based or not before
 	 * kicking migration.
 	 */
-	if (!hugepage_migration_supported(page_hstate(hpage))) {
-		putback_active_hugepage(hpage);
+	if (!hugepage_migration_supported(page_hstate(hpage)))
 		return -ENOSYS;
-	}
 
 	new_hpage = get_new_page(hpage, private, &result);
 	if (!new_hpage)
@@ -1051,9 +1036,6 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
 
 	unlock_page(hpage);
 out:
-	if (rc != -EAGAIN)
-		putback_active_hugepage(hpage);
-
 	/*
 	 * If migration was not successful and there's a freeing callback, use
 	 * it.  Otherwise, put_page() will drop the reference grabbed during
@@ -1129,7 +1111,8 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
 				goto out;
 			case -EAGAIN:
 				retry++;
-				break;
+				/* Keep that page for next pass */
+				continue;
 			case MIGRATEPAGE_SUCCESS:
 				nr_succeeded++;
 				break;
@@ -1143,6 +1126,17 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
 				nr_failed++;
 				break;
 			}
+
+			/* Putback migrated or permanently failed page. */
+			if (PageHuge(page)) {
+				putback_active_hugepage(page);
+			} else {
+				list_del(&page->lru);
+				if (unlikely(isolated_balloon_page(page)))
+					balloon_page_putback(page);
+				else
+					putback_lru_page(page);
+			}
 		}
 	}
 	rc = nr_failed + retry;

--
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>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]