Commit 35dca71c1fad13616d9ea336c05730071793b63a

Authored by Yasuaki Ishimatsu
Committed by Linus Torvalds
1 parent eaf3a65908

memory-hotplug: clear pgdat which is allocated by bootmem in try_offline_node()

When hot adding the same memory after hot removal, the following
messages are shown:

  WARNING: CPU: 20 PID: 6 at mm/page_alloc.c:4968 free_area_init_node+0x3fe/0x426()
  ...
  Call Trace:
    dump_stack+0x46/0x58
    warn_slowpath_common+0x81/0xa0
    warn_slowpath_null+0x1a/0x20
    free_area_init_node+0x3fe/0x426
    hotadd_new_pgdat+0x90/0x110
    add_memory+0xd4/0x200
    acpi_memory_device_add+0x1aa/0x289
    acpi_bus_attach+0xfd/0x204
    acpi_bus_attach+0x178/0x204
    acpi_bus_scan+0x6a/0x90
    acpi_device_hotplug+0xe8/0x418
    acpi_hotplug_work_fn+0x1f/0x2b
    process_one_work+0x14e/0x3f0
    worker_thread+0x11b/0x510
    kthread+0xe1/0x100
    ret_from_fork+0x7c/0xb0

The detaled explanation is as follows:

When hot removing memory, pgdat is set to 0 in try_offline_node().  But
if the pgdat is allocated by bootmem allocator, the clearing step is
skipped.

And when hot adding the same memory, the uninitialized pgdat is reused.
But free_area_init_node() checks wether pgdat is set to zero.  As a
result, free_area_init_node() hits WARN_ON().

This patch clears pgdat which is allocated by bootmem allocator in
try_offline_node().

Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Cc: Zhang Zhen <zhenzhang.zhang@huawei.com>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: Tang Chen <tangchen@cn.fujitsu.com>
Reviewed-by: Toshi Kani <toshi.kani@hp.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 0 additions and 5 deletions Side-by-side Diff

... ... @@ -1912,7 +1912,6 @@
1912 1912 unsigned long start_pfn = pgdat->node_start_pfn;
1913 1913 unsigned long end_pfn = start_pfn + pgdat->node_spanned_pages;
1914 1914 unsigned long pfn;
1915   - struct page *pgdat_page = virt_to_page(pgdat);
1916 1915 int i;
1917 1916  
1918 1917 for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) {
... ... @@ -1940,10 +1939,6 @@
1940 1939 */
1941 1940 node_set_offline(nid);
1942 1941 unregister_one_node(nid);
1943   -
1944   - if (!PageSlab(pgdat_page) && !PageCompound(pgdat_page))
1945   - /* node data is allocated from boot memory */
1946   - return;
1947 1942  
1948 1943 /* free waittable in each zone */
1949 1944 for (i = 0; i < MAX_NR_ZONES; i++) {