Skip to contentSkip to conversation

mm: page_isolation: remove redundant moving for isolated buddy pages

PATCH In review Weijie Yang 2 participants 2 messages Dec 9, 2014

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

PATCH 1/3 mm: page_isolation: remove redundant moving for isolated buddy pages

The commit ad53f92e(fix incorrect isolation behavior by rechecking migratetype) patch series describe the race between page isolation and alloc/free path, and fix the race.

Now, after the pageblock has been isolated, free buddy pages are already in the free_list[MIGRATE_ISOLATE] and will not be allocated for usage. So the current freepage_migratetype check is unnecessary and it will cause redundant page move. That is to say, even if the buddy page's migratetype is not MIGRATE_ISOLATE, the page is in free_list[MIGRATE_ISOLATE], we just move it from free_list[MIGRATE_ISOLATE] to free_list[MIGRATE_ISOLATE].

This patch removes the unnecessary freepage_migratetype check and the redundant page moving.

---
 mm/page_isolation.c |   17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)
mm/page_isolation.c +1 -16
index c8778f7..6e5174d 100644
@@ -221,23 +221,8 @@ __test_page_isolated_in_pageblock(unsigned long pfn, unsigned long end_pfn,
 			continue;
 		}
 		page = pfn_to_page(pfn);
-		if (PageBuddy(page)) {
-			/*
-			 * If race between isolatation and allocation happens,
-			 * some free pages could be in MIGRATE_MOVABLE list
-			 * although pageblock's migratation type of the page
-			 * is MIGRATE_ISOLATE. Catch it and move the page into
-			 * MIGRATE_ISOLATE list.
-			 */
-			if (get_freepage_migratetype(page) != MIGRATE_ISOLATE) {
-				struct page *end_page;
-
-				end_page = page + (1 << page_order(page)) - 1;
-				move_freepages(page_zone(page), page, end_page,
-						MIGRATE_ISOLATE);
-			}
+		if (PageBuddy(page))
 			pfn += 1 << page_order(page);
-		}
 		else if (page_count(page) == 0 &&
 			get_freepage_migratetype(page) == MIGRATE_ISOLATE)
 			pfn += 1;
Signature · 1 line
1.7.10.4
Acked-by on v1 1/3
#1 lore raw
Quoted 11 lines · Weijie Yang

The commit ad53f92e(fix incorrect isolation behavior by rechecking migratetype) patch series describe the race between page isolation and alloc/free path, and fix the race.

Now, after the pageblock has been isolated, free buddy pages are already in the free_list[MIGRATE_ISOLATE] and will not be allocated for usage. So the current freepage_migratetype check is unnecessary and it will cause redundant page move. That is to say, even if the buddy page's migratetype is not MIGRATE_ISOLATE, the page is in free_list[MIGRATE_ISOLATE], we just move it from free_list[MIGRATE_ISOLATE] to free_list[MIGRATE_ISOLATE].

Quoted 4 lines

This patch removes the unnecessary freepage_migratetype check and the redundant page moving.

With great hope that Joonsoo won't find another corner case J

Quoted 24 lines
---
  mm/page_isolation.c |   17 +----------------
  1 file changed, 1 insertion(+), 16 deletions(-)
mm/page_isolation.c +0 -11
index c8778f7..6e5174d 100644
@@ -221,23 +221,8 @@ __test_page_isolated_in_pageblock(unsigned long pfn, unsigned long end_pfn,
  			continue;
  		}
  		page = pfn_to_page(pfn);
-		if (PageBuddy(page)) {
-			/*
-			 * If race between isolatation and allocation happens,
-			 * some free pages could be in MIGRATE_MOVABLE list
-			 * although pageblock's migratation type of the page
-			 * is MIGRATE_ISOLATE. Catch it and move the page into
-			 * MIGRATE_ISOLATE list.
-			 */
-			if (get_freepage_migratetype(page) != MIGRATE_ISOLATE) {
-				struct page *end_page;
-

mm/page_isolation.c __test_page_isolated_in_pageblock(unsigned long pfn, unsigned long end_pfn, · line 228

Quoted 10 lines
mm/page_isolation.c +1 -5
-				end_page = page + (1 << page_order(page)) - 1;
-				move_freepages(page_zone(page), page, end_page,
-						MIGRATE_ISOLATE);
-			}
+		if (PageBuddy(page))
  			pfn += 1 << page_order(page);
-		}
  		else if (page_count(page) == 0 &&
  			get_freepage_migratetype(page) == MIGRATE_ISOLATE)
  			pfn += 1;

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