Commit f14851af authored by qiuxishi's avatar qiuxishi Committed by Linus Torvalds

memory hotplug: fix section info double registration bug

There may be a bug when registering section info.  For example, on my
Itanium platform, the pfn range of node0 includes the other nodes, so
other nodes' section info will be double registered, and memmap's page
count will equal to 3.

  node0: start_pfn=0x100,    spanned_pfn=0x20fb00, present_pfn=0x7f8a3, => 0x000100-0x20fc00
  node1: start_pfn=0x80000,  spanned_pfn=0x80000,  present_pfn=0x80000, => 0x080000-0x100000
  node2: start_pfn=0x100000, spanned_pfn=0x80000,  present_pfn=0x80000, => 0x100000-0x180000
  node3: start_pfn=0x180000, spanned_pfn=0x80000,  present_pfn=0x80000, => 0x180000-0x200000


When hot remove memory, we can't free the memmap's page because
page_count() is 2 after put_page_bootmem().


[ add code comment]
Signed-off-by: default avatarXishi Qiu <>
Signed-off-by: default avatarJiang Liu <>
Acked-by: default avatarMel Gorman <>
Cc: "Luck, Tony" <>
Cc: Yasuaki Ishimatsu <>
Cc: <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 0ba8f2d5
......@@ -126,9 +126,6 @@ static void register_page_bootmem_info_section(unsigned long start_pfn)
struct mem_section *ms;
struct page *page, *memmap;
if (!pfn_valid(start_pfn))
section_nr = pfn_to_section_nr(start_pfn);
ms = __nr_to_section(section_nr);
......@@ -187,9 +184,16 @@ void register_page_bootmem_info_node(struct pglist_data *pgdat)
end_pfn = pfn + pgdat->node_spanned_pages;
/* register_section info */
for (; pfn < end_pfn; pfn += PAGES_PER_SECTION)
for (; pfn < end_pfn; pfn += PAGES_PER_SECTION) {
* Some platforms can assign the same pfn to multiple nodes - on
* node0 as well as nodeN. To avoid registering a pfn against
* multiple nodes we check that this pfn does not already
* reside in some other node.
if (pfn_valid(pfn) && (pfn_to_nid(pfn) == node))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment