linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch -mm 1/2] mm/compaction: split freepages without holding the zone lock fix
@ 2016-06-21 21:47 David Rientjes
  2016-06-21 21:47 ` [patch -mm 2/2] mm, compaction: abort free scanner if split fails David Rientjes
  2016-06-22  1:22 ` [patch] " David Rientjes
  0 siblings, 2 replies; 13+ messages in thread
From: David Rientjes @ 2016-06-21 21:47 UTC (permalink / raw)
  To: Andrew Morton, Vlastimil Babka, Minchan Kim, Joonsoo Kim
  Cc: Mel Gorman, Hugh Dickins, linux-kernel, linux-mm

If __isolate_free_page() fails, avoid adding to freelist so we don't call
map_pages() with it.

Signed-off-by: David Rientjes <rientjes@google.com>
---
 Fix for mm-compaction-split-freepages-without-holding-the-zone-lock.patch in
 -mm.

 mm/compaction.c | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/mm/compaction.c b/mm/compaction.c
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -494,24 +494,21 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
 
 		/* Found a free page, will break it into order-0 pages */
 		order = page_order(page);
-		isolated = __isolate_free_page(page, page_order(page));
+		isolated = __isolate_free_page(page, order);
+		if (!isolated)
+			goto isolate_fail;
 		set_page_private(page, order);
 		total_isolated += isolated;
 		list_add_tail(&page->lru, freelist);
-
-		/* If a page was split, advance to the end of it */
-		if (isolated) {
-			cc->nr_freepages += isolated;
-			if (!strict &&
-				cc->nr_migratepages <= cc->nr_freepages) {
-				blockpfn += isolated;
-				break;
-			}
-
-			blockpfn += isolated - 1;
-			cursor += isolated - 1;
-			continue;
+		cc->nr_freepages += isolated;
+		if (!strict && cc->nr_migratepages <= cc->nr_freepages) {
+			blockpfn += isolated;
+			break;
 		}
+		/* Advance to end of split page */
+		blockpfn += isolated - 1;
+		cursor += isolated - 1;
+		continue;
 
 isolate_fail:
 		if (strict)
@@ -622,7 +619,7 @@ isolate_freepages_range(struct compact_control *cc,
 		 */
 	}
 
-	/* split_free_page does not map the pages */
+	/* __isolate_free_page() does not map the pages */
 	map_pages(&freelist);
 
 	if (pfn < end_pfn) {
@@ -1124,7 +1121,7 @@ static void isolate_freepages(struct compact_control *cc)
 		}
 	}
 
-	/* split_free_page does not map the pages */
+	/* __isolate_free_page() does not map the pages */
 	map_pages(freelist);
 
 	/*

^ permalink raw reply	[flat|nested] 13+ messages in thread
* [patch] mm, compaction: ignore watermarks when isolating free pages
@ 2016-06-15 22:34 David Rientjes
  2016-06-16  7:15 ` Vlastimil Babka
  0 siblings, 1 reply; 13+ messages in thread
From: David Rientjes @ 2016-06-15 22:34 UTC (permalink / raw)
  To: Andrew Morton, Mel Gorman
  Cc: Hugh Dickins, Vlastimil Babka, Joonsoo Kim, linux-kernel, linux-mm

The goal of memory compaction is to defragment memory by moving migratable 
pages to free pages at the end of the zone.  No additional memory is being 
allocated.

Ignore per-zone low watermarks in __isolate_free_page() because memory is 
either fully migrated or isolated free pages are returned when migration 
fails.

This fixes an issue where the compaction freeing scanner can isolate 
memory but the zone drops below its low watermark for that page order, so 
the scanner must continue to scan all memory pointlessly.

Signed-off-by: David Rientjes <rientjes@google.com>
---
 mm/page_alloc.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2484,23 +2484,14 @@ EXPORT_SYMBOL_GPL(split_page);
 
 int __isolate_free_page(struct page *page, unsigned int order)
 {
-	unsigned long watermark;
 	struct zone *zone;
-	int mt;
+	const int mt = get_pageblock_migratetype(page);
 
 	BUG_ON(!PageBuddy(page));
-
 	zone = page_zone(page);
-	mt = get_pageblock_migratetype(page);
-
-	if (!is_migrate_isolate(mt)) {
-		/* Obey watermarks as if the page was being allocated */
-		watermark = low_wmark_pages(zone) + (1 << order);
-		if (!zone_watermark_ok(zone, 0, watermark, 0, 0))
-			return 0;
 
+	if (!is_migrate_isolate(mt))
 		__mod_zone_freepage_state(zone, -(1UL << order), mt);
-	}
 
 	/* Remove page from free list */
 	list_del(&page->lru);
@@ -2520,7 +2511,6 @@ int __isolate_free_page(struct page *page, unsigned int order)
 		}
 	}
 
-
 	return 1UL << order;
 }
 

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-06-23 11:22 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-21 21:47 [patch -mm 1/2] mm/compaction: split freepages without holding the zone lock fix David Rientjes
2016-06-21 21:47 ` [patch -mm 2/2] mm, compaction: abort free scanner if split fails David Rientjes
2016-06-22  1:22 ` [patch] " David Rientjes
2016-06-22 11:02   ` Vlastimil Babka
2016-06-22 21:56   ` Andrew Morton
2016-06-22 21:59     ` Andrew Morton
2016-06-22 23:40       ` David Rientjes
2016-06-23 11:21         ` Vlastimil Babka
2016-06-22 22:06     ` David Rientjes
2016-06-22 22:42       ` Andrew Morton
  -- strict thread matches above, loose matches on Subject: below --
2016-06-15 22:34 [patch] mm, compaction: ignore watermarks when isolating free pages David Rientjes
2016-06-16  7:15 ` Vlastimil Babka
2016-06-20 22:27   ` [patch] mm, compaction: abort free scanner if split fails David Rientjes
2016-06-21 11:43     ` Vlastimil Babka
2016-06-21 20:43       ` David Rientjes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).