Skip to contentSkip to conversation

4/4 Migration Cache - use for direct migration

RFC In review Lee Schermerhorn 2 participants 3 messages Feb 17, 2006

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC 1/1 4/4 Migration Cache - use for direct migration

Migration Cache "V8" 4/4

This patch hooks the migration cache up to direct page migration. If a destination page exists, and the old page is not already in a swap cache, we place it in the migration cache instead.

If direct migration is successful, the page will be removed by remove_from_swap(), et al. If migration is not successful after 4 or 5 passes, migrate_pages() drops back to swapping. In this case, we must move the page from the migration cache to the swap cache.

mm/vmscan.c +12 -1
Index: linux-2.6.16-rc3-mm1/mm/vmscan.c
===================================================================
@@ -911,7 +911,12 @@ redo:
 		 * preserved.
 		 */
 		if (PageAnon(page) && !PageSwapCache(page)) {
-			if (!add_to_swap(page, GFP_KERNEL)) {
+			if (!to) {
+				if (!add_to_swap(page, GFP_KERNEL)) {
+					rc = -ENOMEM;
+					goto unlock_page;
+				}
+			} else if (add_to_migration_cache(page, GFP_KERNEL)) {
 				rc = -ENOMEM;
 				goto unlock_page;
 			}
@@ -989,6 +994,12 @@ redo:
 			 */
 			unlock_page(newpage);
 			newpage = NULL;
+			if (page_is_migration(page)) {
+				if (!migration_move_to_swap(page)) {
+					rc = -ENOMEM;
+					goto unlock_page;
+				}
+			}
 			rc = swap_page(page);
 			goto next;
 		}

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw
Quoted 8 lines · Lee Schermerhorn

Index: linux-2.6.16-rc3-mm1/mm/vmscan.c
===================================================================

mm/vmscan.c +0 -0
@@ -911,7 +911,12 @@ redo:
 		 * preserved.
 		 */
 		if (PageAnon(page) && !PageSwapCache(page)) {

mm/vmscan.c redo: · line 922

Quoted 10 lines
mm/vmscan.c +6 -1
-			if (!add_to_swap(page, GFP_KERNEL)) {
+			if (!to) {
+				if (!add_to_swap(page, GFP_KERNEL)) {
+					rc = -ENOMEM;
+					goto unlock_page;
+				}
+			} else if (add_to_migration_cache(page, GFP_KERNEL)) {
 				rc = -ENOMEM;
 				goto unlock_page;
 			}

Hmmm.... maybe add another parameter to add_to_swap instead? This seems to be duplicating some code.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#2 lore raw
Quoted 15 lines · Christoph Lameter
Quoted 13 lines · Lee Schermerhorn

Index: linux-2.6.16-rc3-mm1/mm/vmscan.c
===================================================================

mm/vmscan.c +4 -1
@@ -911,7 +911,12 @@ redo:
 		 * preserved.
 		 */
 		if (PageAnon(page) && !PageSwapCache(page)) {
-			if (!add_to_swap(page, GFP_KERNEL)) {
+			if (!to) {
+				if (!add_to_swap(page, GFP_KERNEL)) {
+					rc = -ENOMEM;
+					goto unlock_page;
Quoted 9 lines

mm/vmscan.c redo: · line 922

Quoted 5 lines
mm/vmscan.c +2 -0
+				}
+			} else if (add_to_migration_cache(page, GFP_KERNEL)) {
 				rc = -ENOMEM;
 				goto unlock_page;
 			}

Hmmm.... maybe add another parameter to add_to_swap instead? This seems to be duplicating some code.

Could do. The value of which would depend on 'to' in this context.

This would require a change to shrink_list() in vmscan which you wanted to avoid in comment on previous mail, or we could leave add_to_swap() as a wrapper over the current one renamed to __add_to_swap or such with the extra parameter.

Could also change the code above to use a single if:

if ((!to && !add_to_swap()) || (to && add_to_migration_cache())) ...

I'm not too clear on what passes for "readability" and how that weighs against this level code duplication. ;-)

But, in general, I agree with the notion of hiding the details or even existence of the migration cache behind the swap interfaces.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>