Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1456351 > unrolled thread

[PATCH 1/3] mm: fix set pageblock migratetype in deferred struct page init

Started byXishi Qiu <qiuxishi@huawei.com>
First post2016-08-04 13:30 +0200
Last post2016-08-04 13:50 +0200
Articles 2 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 1/3] mm: fix set pageblock migratetype in deferred struct  page init Xishi Qiu <qiuxishi@huawei.com> - 2016-08-04 13:30 +0200
    Re: [PATCH 1/3] mm: fix set pageblock migratetype in deferred struct  page init Xishi Qiu <qiuxishi@huawei.com> - 2016-08-04 13:50 +0200

#1456351 — [PATCH 1/3] mm: fix set pageblock migratetype in deferred struct page init

FromXishi Qiu <qiuxishi@huawei.com>
Date2016-08-04 13:30 +0200
Subject[PATCH 1/3] mm: fix set pageblock migratetype in deferred struct page init
Message-ID<s2p0B-8g0-5@gated-at.bofh.it>
MAX_ORDER_NR_PAGES is usually 4M, and a pageblock is usually 2M, so we only
set one pageblock's migratetype in deferred_free_range() if pfn is aligned
to MAX_ORDER_NR_PAGES.

Also we missed to free the last block in deferred_init_memmap().

Signed-off-by: Xishi Qiu <qiuxishi@huawei.com>
---
 mm/page_alloc.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 2b258ec..e0ec3b6 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1399,15 +1399,18 @@ static void __init deferred_free_range(struct page *page,
 		return;
 
 	/* Free a large naturally-aligned chunk if possible */
-	if (nr_pages == MAX_ORDER_NR_PAGES &&
-	    (pfn & (MAX_ORDER_NR_PAGES-1)) == 0) {
+	if (nr_pages == pageblock_nr_pages &&
+	    (pfn & (pageblock_nr_pages - 1)) == 0) {
 		set_pageblock_migratetype(page, MIGRATE_MOVABLE);
-		__free_pages_boot_core(page, MAX_ORDER-1);
+		__free_pages_boot_core(page, pageblock_order);
 		return;
 	}
 
-	for (i = 0; i < nr_pages; i++, page++)
+	for (i = 0; i < nr_pages; i++, page++, pfn++) {
+		if ((pfn & (pageblock_nr_pages - 1)) == 0)
+			set_pageblock_migratetype(page, MIGRATE_MOVABLE);
 		__free_pages_boot_core(page, 0);
+	}
 }
 
 /* Completion tracking for deferred_init_memmap() threads */
@@ -1475,9 +1478,9 @@ static int __init deferred_init_memmap(void *data)
 
 			/*
 			 * Ensure pfn_valid is checked every
-			 * MAX_ORDER_NR_PAGES for memory holes
+			 * pageblock_nr_pages for memory holes
 			 */
-			if ((pfn & (MAX_ORDER_NR_PAGES - 1)) == 0) {
+			if ((pfn & (pageblock_nr_pages - 1)) == 0) {
 				if (!pfn_valid(pfn)) {
 					page = NULL;
 					goto free_range;
@@ -1490,7 +1493,7 @@ static int __init deferred_init_memmap(void *data)
 			}
 
 			/* Minimise pfn page lookups and scheduler checks */
-			if (page && (pfn & (MAX_ORDER_NR_PAGES - 1)) != 0) {
+			if (page && (pfn & (pageblock_nr_pages - 1)) != 0) {
 				page++;
 			} else {
 				nr_pages += nr_to_free;
@@ -1526,6 +1529,9 @@ free_range:
 			free_base_page = NULL;
 			free_base_pfn = nr_to_free = 0;
 		}
+		/* Free the last block of pages to allocator */
+		nr_pages += nr_to_free;
+		deferred_free_range(free_base_page, free_base_pfn, nr_to_free);
 
 		first_init_pfn = max(end_pfn, first_init_pfn);
 	}
-- 
1.8.3.1

[toc] | [next] | [standalone]


#1456360

FromXishi Qiu <qiuxishi@huawei.com>
Date2016-08-04 13:50 +0200
Message-ID<s2pjY-8pF-5@gated-at.bofh.it>
In reply to#1456351
On 2016/8/4 19:25, Xishi Qiu wrote:

> MAX_ORDER_NR_PAGES is usually 4M, and a pageblock is usually 2M, so we only
> set one pageblock's migratetype in deferred_free_range() if pfn is aligned
> to MAX_ORDER_NR_PAGES.
> 
> Also we missed to free the last block in deferred_init_memmap().
> 
> Signed-off-by: Xishi Qiu <qiuxishi@huawei.com>

Sorry for the typo, this patch is 3/3, and 1/3 is this one
"[PATCH 1/3] mem-hotplug: introduce movablenode option"

However they are all independent.

Thanks,
Xishi Qiu

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web