memory-hotplug: add hot-added memory ranges to memblock before allocate node_data...
authorTang Chen <[email protected]>
Fri, 4 Sep 2015 22:42:32 +0000 (15:42 -0700)
committerLinus Torvalds <[email protected]>
Fri, 4 Sep 2015 23:54:41 +0000 (16:54 -0700)
commit7f36e3e56db1ae75d1e157011b3cb2e0957f0a7e
tree1816ea71cb2758627f887c001bbfa4b7789de7d9
parent88a99886c26fec8bf662e7b6bc080431a8660326
memory-hotplug: add hot-added memory ranges to memblock before allocate node_data for a node.

Commit f9126ab9241f ("memory-hotplug: fix wrong edge when hot add a new
node") hot-added memory range to memblock, after creating pgdat for new
node.

But there is a problem:

  add_memory()
  |--> hotadd_new_pgdat()
       |--> free_area_init_node()
            |--> get_pfn_range_for_nid()
                 |--> find start_pfn and end_pfn in memblock
  |--> ......
  |--> memblock_add_node(start, size, nid)    --------    Here, just too late.

get_pfn_range_for_nid() will find that start_pfn and end_pfn are both 0.
As a result, when adding memory, dmesg will give the following wrong
message.

  Initmem setup node 5 [mem 0x0000000000000000-0xffffffffffffffff]
  On node 5 totalpages: 0
  Built 5 zonelists in Node order, mobility grouping on.  Total pages: 32588823
  Policy zone: Normal
  init_memory_mapping: [mem 0x60000000000-0x607ffffffff]

The solution is simple, just add the memory range to memblock a little
earlier, before hotadd_new_pgdat().

[[email protected]: coding-style fixes]
Signed-off-by: Tang Chen <[email protected]>
Cc: Xishi Qiu <[email protected]>
Cc: Yasuaki Ishimatsu <[email protected]>
Cc: Kamezawa Hiroyuki <[email protected]>
Cc: Taku Izumi <[email protected]>
Cc: Gu Zheng <[email protected]>
Cc: Naoya Horiguchi <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: <[email protected]> [4.2.x]
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/memory_hotplug.c