Linux-mm Archive on
 help / color / Atom feed
* [patch 079/158] mm/page_alloc.c: don't set pages PageReserved() when offlining
@ 2019-12-01  1:54 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2019-12-01  1:54 UTC (permalink / raw)
  To: akpm, alexander.h.duyck, anshuman.khandual, cai, dan.j.williams,
	david, kernelfans, linux-mm, mgorman, mhocko, mm-commits,
	osalvador, pasha.tatashin, pavel.tatashin, richard.weiyang, rppt,
	rppt, torvalds, vbabka

From: David Hildenbrand <>
Subject: mm/page_alloc.c: don't set pages PageReserved() when offlining

Patch series "mm: Memory offlining + page isolation cleanups", v2.

This patch (of 2):

We call __offline_isolated_pages() from __offline_pages() after all pages
were isolated and are either free (PageBuddy()) or PageHWPoison.  Nothing
can stop us from offlining memory at this point.

In __offline_isolated_pages() we first set all affected memory sections
offline (offline_mem_sections(pfn, end_pfn)), to mark the memmap as
invalid (pfn_to_online_page() will no longer succeed), and then walk over
all pages to pull the free pages from the free lists (to the isolated free
lists, to be precise).

Note that re-onlining a memory block will result in the whole memmap
getting reinitialized, overwriting any old state.  We already poision the
memmap when offlining is complete to find any access to
stale/uninitialized memmaps.

So, setting the pages PageReserved() is not helpful.  The memap is marked
offline and all pageblocks are isolated.  As soon as offline, the memmap
is stale either way.

This looks like a leftover from ancient times where we initialized the
memmap when adding memory and not when onlining it (the pages were set
PageReserved so re-onling would work as expected).

Signed-off-by: David Hildenbrand <>
Acked-by: Michal Hocko <>
Cc: Vlastimil Babka <>
Cc: Oscar Salvador <>
Cc: Mel Gorman <>
Cc: Mike Rapoport <>
Cc: Dan Williams <>
Cc: Wei Yang <>
Cc: Alexander Duyck <>
Cc: Anshuman Khandual <>
Cc: Pavel Tatashin <>
Cc: Mike Rapoport <>
Cc: Pavel Tatashin <>
Cc: Pingfan Liu <>
Cc: Qian Cai <>
Signed-off-by: Andrew Morton <>

 mm/memory_hotplug.c |    4 +---
 mm/page_alloc.c     |    5 +----
 2 files changed, 2 insertions(+), 7 deletions(-)

--- a/mm/memory_hotplug.c~mm-page_allocc-dont-set-pages-pagereserved-when-offlining
+++ a/mm/memory_hotplug.c
@@ -1384,9 +1384,7 @@ do_migrate_range(unsigned long start_pfn
 	return ret;
- * remove from free_area[] and mark all as Reserved.
- */
+/* Mark all sections offline and remove all free pages from the buddy. */
 static int
 offline_isolated_pages_cb(unsigned long start, unsigned long nr_pages,
 			void *data)
--- a/mm/page_alloc.c~mm-page_allocc-dont-set-pages-pagereserved-when-offlining
+++ a/mm/page_alloc.c
@@ -8560,7 +8560,7 @@ __offline_isolated_pages(unsigned long s
 	struct page *page;
 	struct zone *zone;
-	unsigned int order, i;
+	unsigned int order;
 	unsigned long pfn;
 	unsigned long flags;
 	unsigned long offlined_pages = 0;
@@ -8588,7 +8588,6 @@ __offline_isolated_pages(unsigned long s
 		if (unlikely(!PageBuddy(page) && PageHWPoison(page))) {
-			SetPageReserved(page);
@@ -8602,8 +8601,6 @@ __offline_isolated_pages(unsigned long s
 			pfn, 1 << order, end_pfn);
 		del_page_from_free_area(page, &zone->free_area[order]);
-		for (i = 0; i < (1 << order); i++)
-			SetPageReserved((page+i));
 		pfn += (1 << order);
 	spin_unlock_irqrestore(&zone->lock, flags);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-01  1:54 [patch 079/158] mm/page_alloc.c: don't set pages PageReserved() when offlining akpm

Linux-mm Archive on

Archives are clonable:
	git clone --mirror linux-mm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mm linux-mm/ \
	public-inbox-index linux-mm

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone