Skip to contentSkip to conversation

memory-hotplug: fix wrong edge when hot add a new node

PATCH In review Xishi Qiu 2 participants 7 messages Aug 11, 2015 – Aug 26, 2015

Subsystems (3)
lore
Share & tools
lore

Xishi Qiu

author
#0 lore raw

PATCH 1/2 memory-hotplug: fix wrong edge when hot add a new node

When we add a new node, the edge of memory may be wrong.

e.g. system has 4 nodes, and node3 is movable, node3 mem:[24G-32G],

1. hotremove the node3,
2. then hotadd node3 with a part of memory, mem:[26G-30G],
3. call hotadd_new_pgdat()

	free_area_init_node()
		get_pfn_range_for_nid() 

4. it will return wrong start_pfn and end_pfn, because we have not update the memblock.

This patch also fix another bug, please see
http://marc.info/?l=linux-kernel&m=142961156129456&w=2

---
 mm/memory_hotplug.c | 3 +++
 mm/page_alloc.c     | 8 ++++++++
 2 files changed, 11 insertions(+)
mm/memory_hotplug.c +3 -0
index 26fbba7..11f26cc 100644
@@ -1269,6 +1269,7 @@ int __ref add_memory(int nid, u64 start, u64 size)
 
 	/* create new memmap entry */
 	firmware_map_add_hotplug(start, start + size, "System RAM");
+	memblock_add_node(start, size, nid);
 
 	goto out;
 
@@ -2005,6 +2006,8 @@ void __ref remove_memory(int nid, u64 start, u64 size)
 
 	/* remove memmap entry */
 	firmware_map_remove(start, start + size, "System RAM");
+	memblock_free(start, size);
+	memblock_remove(start, size);
 
 	arch_remove_memory(start, size);
 
mm/page_alloc.c +8 -0
index 1b91d37..7ca12b9 100644
@@ -5050,6 +5050,10 @@ static unsigned long __meminit zone_spanned_pages_in_node(int nid,
 {
 	unsigned long zone_start_pfn, zone_end_pfn;
 
+	/* When hotadd a new node, the node should be empty */
+	if (!node_start_pfn && !node_end_pfn)
+		return 0;
+
 	/* Get the start and end of the zone */
 	zone_start_pfn = arch_zone_lowest_possible_pfn[zone_type];
 	zone_end_pfn = arch_zone_highest_possible_pfn[zone_type];
@@ -5113,6 +5117,10 @@ static unsigned long __meminit zone_absent_pages_in_node(int nid,
 	unsigned long zone_high = arch_zone_highest_possible_pfn[zone_type];
 	unsigned long zone_start_pfn, zone_end_pfn;
 
+	/* When hotadd a new node, the node should be empty */
+	if (!node_start_pfn && !node_end_pfn)
+		return 0;
+
 	zone_start_pfn = clamp(node_start_pfn, zone_low, zone_high);
 	zone_end_pfn = clamp(node_end_pfn, zone_low, zone_high);
 
Signature · 1 line
2.0.0
author
#1 lore raw

PATCH 2/2 memory-hotplug: remove reset_node_managed_pages() and reset_node_managed_pages() in hotadd_new_pgdat()

After hotadd_new_pgdat()->free_area_init_node(), the pgdat and zone's spanned/present are both 0, so remove reset_node_managed_pages() and reset_node_managed_pages().

---
 mm/memory_hotplug.c | 25 -------------------------
 1 file changed, 25 deletions(-)
mm/memory_hotplug.c +0 -25
index 11f26cc..997dfad 100644
@@ -1065,16 +1065,6 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ
 }
 #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
 
-static void reset_node_present_pages(pg_data_t *pgdat)
-{
-	struct zone *z;
-
-	for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++)
-		z->present_pages = 0;
-
-	pgdat->node_present_pages = 0;
-}
-
 /* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */
 static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start)
 {
@@ -1109,21 +1099,6 @@ static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start)
 	build_all_zonelists(pgdat, NULL);
 	mutex_unlock(&zonelists_mutex);
 
-	/*
-	 * zone->managed_pages is set to an approximate value in
-	 * free_area_init_core(), which will cause
-	 * /sys/device/system/node/nodeX/meminfo has wrong data.
-	 * So reset it to 0 before any memory is onlined.
-	 */
-	reset_node_managed_pages(pgdat);
-
-	/*
-	 * When memory is hot-added, all the memory is in offline state. So
-	 * clear all zones' present_pages because they will be updated in
-	 * online_pages() and offline_pages().
-	 */
-	reset_node_present_pages(pgdat);
-
 	return pgdat;
 }
 
Signature · 1 line
2.0.0
#2 lore raw

Re: [PATCH 2/2] memory-hotplug: remove reset_node_managed_pages() and reset_node_managed_pages() in hotadd_new_pgdat()

Hi Shi,

Sorry for the late reply. I hope it won't be too late.

NON-ACK by me, I think.

I noticed that your first has been merged. But it won't fix the problem these code intended to fix.

After your patch 1, zone's spanned/present won't be set to 0 because:

free_area_init_node()
|--> get_pfn_range_for_nid(&start_pfn, &end_pfn) |--> calculate_node_totalpages(pgdat, start_pfn, end_pfn, ...)

         | --> zone_spanned_pages_in_node()
                  | --> if (!node_start_pfn && !node_end_pfn) return 
0;    --------    false, won't return 0
         | --> zone_absent_pages_in_node()
                  | --> if (!node_start_pfn && !node_end_pfn) return 

0; -------- false, won't return 0

This is caused by a little bug in your patch 1.

You should put memblock_add_node(start, size, nid) before hotadd_new_pgdat() because:

hotadd_new_pgdat()
| --> free_area_init_node()

          | --> get_pfn_range_for_nid()
                   | --> find memory ranges in memblock.

| --> memblock_add_node(start, size, nid) ------------------- if you add it here, it doesn't work.

The result will be like below if we hotadd node 5.

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

And also, if we merge this patch, /sys/devices/system/node/nodeX/meminfo will break.

Since this patch is not merged, I think let's just drop it.

And about the little bug in your patch 1, since I'm in a hurry, I have already send a patch to fix it.

Thanks. :)

Quoted 51 lines · Xishi Qiu

After hotadd_new_pgdat()->free_area_init_node(), the pgdat and zone's spanned/present are both 0, so remove reset_node_managed_pages() and reset_node_managed_pages().

---
  mm/memory_hotplug.c | 25 -------------------------
  1 file changed, 25 deletions(-)
mm/memory_hotplug.c +0 -25
index 11f26cc..997dfad 100644
@@ -1065,16 +1065,6 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ
  }
  #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
 
-static void reset_node_present_pages(pg_data_t *pgdat)
-{
-	struct zone *z;
-
-	for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++)
-		z->present_pages = 0;
-
-	pgdat->node_present_pages = 0;
-}
-
  /* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */
  static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start)
  {
@@ -1109,21 +1099,6 @@ static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start)
  	build_all_zonelists(pgdat, NULL);
  	mutex_unlock(&zonelists_mutex);
 
-	/*
-	 * zone->managed_pages is set to an approximate value in
-	 * free_area_init_core(), which will cause
-	 * /sys/device/system/node/nodeX/meminfo has wrong data.
-	 * So reset it to 0 before any memory is onlined.
-	 */
-	reset_node_managed_pages(pgdat);
-
-	/*
-	 * When memory is hot-added, all the memory is in offline state. So
-	 * clear all zones' present_pages because they will be updated in
-	 * online_pages() and offline_pages().
-	 */
-	reset_node_present_pages(pgdat);
-
  	return pgdat;
  }
 
author
#3 lore raw

Re: [PATCH 2/2] memory-hotplug: remove reset_node_managed_pages() and reset_node_managed_pages() in hotadd_new_pgdat()

Quoted 11 lines · Tang Chen

Hi Shi,

Sorry for the late reply. I hope it won't be too late.

NON-ACK by me, I think.

I noticed that your first has been merged. But it won't fix the problem these code intended to fix.

After your patch 1, zone's spanned/present won't be set to 0 because:

Quoted 8 lines

free_area_init_node()
|--> get_pfn_range_for_nid(&start_pfn, &end_pfn) |--> calculate_node_totalpages(pgdat, start_pfn, end_pfn, ...)

         | --> zone_spanned_pages_in_node()
                  | --> if (!node_start_pfn && !node_end_pfn) return 0;    --------    false, won't return 0
         | --> zone_absent_pages_in_node()
                  | --> if (!node_start_pfn && !node_end_pfn) return 0;    --------    false, won't return 0

Hi Tang,

Thank you for your reply. When we add a new node, it is not included in the memblock, I have no idea why zone_spanned_pages_in_node() and zone_absent_pages_in_node() won't return 0. Do you add some debug code and print it?

Quoted 5 lines

This is caused by a little bug in your patch 1.

You should put memblock_add_node(start, size, nid) before hotadd_new_pgdat() because:

My patch is just add an empty node first, later __add_zone() will update the size. But it is all right put here, and it can fix the print bug.

Quoted 9 lines

hotadd_new_pgdat()
| --> free_area_init_node()

          | --> get_pfn_range_for_nid()
                   | --> find memory ranges in memblock.

| --> memblock_add_node(start, size, nid) ------------------- if you add it here, it doesn't work.

The result will be like below if we hotadd node 5.

[ 2007.577000] Initmem setup node 5 [mem 0x0000000000000000-0xffffffffffffffff]
	pr_info("Initmem setup node %d [mem %#018Lx-%#018Lx]\n", nid,
		(u64)start_pfn << PAGE_SHIFT, ((u64)end_pfn << PAGE_SHIFT) - 1);

start_pfn and end_pfn are both 0, and 0-1 -> 0xffffffffffffffff, right?

Quoted 8 lines
[ 2007.584000] On node 5 totalpages: 0
[ 2007.585000] Built 5 zonelists in Node order, mobility grouping on.  Total pages: 32588823
[ 2007.594000] Policy zone: Normal
[ 2007.598000] init_memory_mapping: [mem 0x60000000000-0x607ffffffff]

And also, if we merge this patch, /sys/devices/system/node/nodeX/meminfo will break.

trigger call trace?

Quoted 63 lines

Since this patch is not merged, I think let's just drop it.

And about the little bug in your patch 1, since I'm in a hurry, I have already send a patch to fix it.

Thanks. :)

Quoted 39 lines · Xishi Qiu

After hotadd_new_pgdat()->free_area_init_node(), the pgdat and zone's spanned/present are both 0, so remove reset_node_managed_pages() and reset_node_managed_pages().

---
  mm/memory_hotplug.c | 25 -------------------------
  1 file changed, 25 deletions(-)
mm/memory_hotplug.c +0 -16
index 11f26cc..997dfad 100644
@@ -1065,16 +1065,6 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ
  }
  #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
  -static void reset_node_present_pages(pg_data_t *pgdat)
-{
-    struct zone *z;
-
-    for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++)
-        z->present_pages = 0;
-
-    pgdat->node_present_pages = 0;
-}
-
  /* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */
  static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start)
  {
@@ -1109,21 +1099,6 @@ static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start)
      build_all_zonelists(pgdat, NULL);
      mutex_unlock(&zonelists_mutex);
  -    /*
-     * zone->managed_pages is set to an approximate value in
-     * free_area_init_core(), which will cause
-     * /sys/device/system/node/nodeX/meminfo has wrong data.
-     * So reset it to 0 before any memory is onlined.
-     */
-    reset_node_managed_pages(pgdat);
-

mm/memory_hotplug.c static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start) · line 1104

Quoted 10 lines
mm/memory_hotplug.c +0 -7
-    /*
-     * When memory is hot-added, all the memory is in offline state. So
-     * clear all zones' present_pages because they will be updated in
-     * online_pages() and offline_pages().
-     */
-    reset_node_present_pages(pgdat);
-
      return pgdat;
  }
 

.

#4 lore raw

Re: [PATCH 2/2] memory-hotplug: remove reset_node_managed_pages() and reset_node_managed_pages() in hotadd_new_pgdat()

Quoted 21 lines · Xishi Qiu
Quoted 11 lines · Tang Chen

Hi Shi,

Sorry for the late reply. I hope it won't be too late.

NON-ACK by me, I think.

I noticed that your first has been merged. But it won't fix the problem these code intended to fix.

After your patch 1, zone's spanned/present won't be set to 0 because:

Quoted 8 lines

free_area_init_node()
|--> get_pfn_range_for_nid(&start_pfn, &end_pfn) |--> calculate_node_totalpages(pgdat, start_pfn, end_pfn, ...)

          | --> zone_spanned_pages_in_node()
                   | --> if (!node_start_pfn && !node_end_pfn) return 0;    --------    false, won't return 0
          | --> zone_absent_pages_in_node()
                   | --> if (!node_start_pfn && !node_end_pfn) return 0;    --------    false, won't return 0
Quoted 5 lines

Hi Tang,

Thank you for your reply. When we add a new node, it is not included in the memblock, I have no idea why zone_spanned_pages_in_node() and zone_absent_pages_in_node() won't return 0. Do you add some debug code and print it?

Sorry, I didn't say it clearly since I was in a hurry.

If we move memblock_add_node() forward before hotadd_new_pgdat(), then node_start_pfn and node_end_pfn won't be 0. And zone_spanned_pages_in_node() and zone_absent_pages_in_node() won't return 0.

In your patch, they will return 0. And that leads to the print problem.

Quoted 8 lines
Quoted 6 lines

This is caused by a little bug in your patch 1.

You should put memblock_add_node(start, size, nid) before hotadd_new_pgdat() because:

My patch is just add an empty node first, later __add_zone() will update the size. But it is all right put here, and it can fix the print bug.

Yes. I just found this bug in the log.

Quoted 6 lines
Quoted 6 lines

hotadd_new_pgdat()
| --> free_area_init_node()

           | --> get_pfn_range_for_nid()
                    | --> find memory ranges in memblock.
Quoted 7 lines
Quoted 4 lines

| --> memblock_add_node(start, size, nid) ------------------- if you add it here, it doesn't work.

The result will be like below if we hotadd node 5.

[ 2007.577000] Initmem setup node 5 [mem 0x0000000000000000-0xffffffffffffffff]
	pr_info("Initmem setup node %d [mem %#018Lx-%#018Lx]\n", nid,
		(u64)start_pfn << PAGE_SHIFT, ((u64)end_pfn << PAGE_SHIFT) - 1);

start_pfn and end_pfn are both 0, and 0-1 -> 0xffffffffffffffff, right?

Yes.

Quoted 10 lines
Quoted 9 lines
[ 2007.584000] On node 5 totalpages: 0
[ 2007.585000] Built 5 zonelists in Node order, mobility grouping on.  Total pages: 32588823
[ 2007.594000] Policy zone: Normal
[ 2007.598000] init_memory_mapping: [mem 0x60000000000-0x607ffffffff]

And also, if we merge this patch, /sys/devices/system/node/nodeX/meminfo will break.

trigger call trace?

No. There is no error output. But if you see /sys/devices/system/node/nodeX/meminfo, memory size will double because totalpages is calculated once here, and one more time when onlining memory.

I think reset it to 0 in add_memory() is just a temporary solution. Will improve it in the future.

Thanks.

Quoted 66 lines
Quoted 53 lines

Since this patch is not merged, I think let's just drop it.

And about the little bug in your patch 1, since I'm in a hurry, I have already send a patch to fix it.

Thanks. :)

Quoted 43 lines · Xishi Qiu

After hotadd_new_pgdat()->free_area_init_node(), the pgdat and zone's spanned/present are both 0, so remove reset_node_managed_pages() and reset_node_managed_pages().

---
   mm/memory_hotplug.c | 25 -------------------------
   1 file changed, 25 deletions(-)
mm/memory_hotplug.c +0 -20
index 11f26cc..997dfad 100644
@@ -1065,16 +1065,6 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ
   }
   #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
   -static void reset_node_present_pages(pg_data_t *pgdat)
-{
-    struct zone *z;
-
-    for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++)
-        z->present_pages = 0;
-
-    pgdat->node_present_pages = 0;
-}
-
   /* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */
   static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start)
   {
@@ -1109,21 +1099,6 @@ static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start)
       build_all_zonelists(pgdat, NULL);
       mutex_unlock(&zonelists_mutex);
   -    /*
-     * zone->managed_pages is set to an approximate value in
-     * free_area_init_core(), which will cause
-     * /sys/device/system/node/nodeX/meminfo has wrong data.
-     * So reset it to 0 before any memory is onlined.
-     */
-    reset_node_managed_pages(pgdat);
-
-    /*
-     * When memory is hot-added, all the memory is in offline state. So
-     * clear all zones' present_pages because they will be updated in
-     * online_pages() and offline_pages().
Quoted 9 lines

mm/memory_hotplug.c static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start) · line 1104

Quoted 6 lines
mm/memory_hotplug.c +0 -3
-     */
-    reset_node_present_pages(pgdat);
-
       return pgdat;
   }
 

.

.

author
#5 lore raw

Re: [PATCH 2/2] memory-hotplug: remove reset_node_managed_pages() and reset_node_managed_pages() in hotadd_new_pgdat()

Quoted 72 lines · Tang Chen
Quoted 21 lines · Xishi Qiu
Quoted 11 lines · Tang Chen

Hi Shi,

Sorry for the late reply. I hope it won't be too late.

NON-ACK by me, I think.

I noticed that your first has been merged. But it won't fix the problem these code intended to fix.

After your patch 1, zone's spanned/present won't be set to 0 because:

Quoted 8 lines

free_area_init_node()
|--> get_pfn_range_for_nid(&start_pfn, &end_pfn) |--> calculate_node_totalpages(pgdat, start_pfn, end_pfn, ...)

          | --> zone_spanned_pages_in_node()
                   | --> if (!node_start_pfn && !node_end_pfn) return 0;    --------    false, won't return 0
          | --> zone_absent_pages_in_node()
                   | --> if (!node_start_pfn && !node_end_pfn) return 0;    --------    false, won't return 0
Quoted 5 lines

Hi Tang,

Thank you for your reply. When we add a new node, it is not included in the memblock, I have no idea why zone_spanned_pages_in_node() and zone_absent_pages_in_node() won't return 0. Do you add some debug code and print it?

Sorry, I didn't say it clearly since I was in a hurry.

If we move memblock_add_node() forward before hotadd_new_pgdat(), then node_start_pfn and node_end_pfn won't be 0. And zone_spanned_pages_in_node() and zone_absent_pages_in_node() won't return 0.

In your patch, they will return 0. And that leads to the print problem.

Quoted 8 lines
Quoted 6 lines

This is caused by a little bug in your patch 1.

You should put memblock_add_node(start, size, nid) before hotadd_new_pgdat() because:

My patch is just add an empty node first, later __add_zone() will update the size. But it is all right put here, and it can fix the print bug.

Yes. I just found this bug in the log.

Quoted 6 lines
Quoted 6 lines

hotadd_new_pgdat()
| --> free_area_init_node()

           | --> get_pfn_range_for_nid()
                    | --> find memory ranges in memblock.
Quoted 7 lines
Quoted 4 lines

| --> memblock_add_node(start, size, nid) ------------------- if you add it here, it doesn't work.

The result will be like below if we hotadd node 5.

[ 2007.577000] Initmem setup node 5 [mem 0x0000000000000000-0xffffffffffffffff]
    pr_info("Initmem setup node %d [mem %#018Lx-%#018Lx]\n", nid,
        (u64)start_pfn << PAGE_SHIFT, ((u64)end_pfn << PAGE_SHIFT) - 1);

start_pfn and end_pfn are both 0, and 0-1 -> 0xffffffffffffffff, right?

Yes.

Quoted 7 lines
Quoted 7 lines
[ 2007.584000] On node 5 totalpages: 0
[ 2007.585000] Built 5 zonelists in Node order, mobility grouping on.  Total pages: 32588823
[ 2007.594000] Policy zone: Normal
[ 2007.598000] init_memory_mapping: [mem 0x60000000000-0x607ffffffff]
Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

And also, if we merge this patch, /sys/devices/system/node/nodeX/meminfo will break.

trigger call trace?

No. There is no error output. But if you see /sys/devices/system/node/nodeX/meminfo, memory size will double because totalpages is calculated once here, and one more time when onlining memory.

Hi Tang,

Do you mean si_meminfo_node() -> val->totalram = managed_pages; will be added double? But my patch will keep it 0 in hotadd_new_pgdat(), so it will not be double, right?

Thanks,
Xishi Qiu

Quoted 75 lines

I think reset it to 0 in add_memory() is just a temporary solution. Will improve it in the future.

Thanks.

Quoted 64 lines
Quoted 53 lines

Since this patch is not merged, I think let's just drop it.

And about the little bug in your patch 1, since I'm in a hurry, I have already send a patch to fix it.

Thanks. :)

Quoted 43 lines · Xishi Qiu

After hotadd_new_pgdat()->free_area_init_node(), the pgdat and zone's spanned/present are both 0, so remove reset_node_managed_pages() and reset_node_managed_pages().

---
   mm/memory_hotplug.c | 25 -------------------------
   1 file changed, 25 deletions(-)
mm/memory_hotplug.c +0 -20
index 11f26cc..997dfad 100644
@@ -1065,16 +1065,6 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ
   }
   #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
   -static void reset_node_present_pages(pg_data_t *pgdat)
-{
-    struct zone *z;
-
-    for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++)
-        z->present_pages = 0;
-
-    pgdat->node_present_pages = 0;
-}
-
   /* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */
   static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start)
   {
@@ -1109,21 +1099,6 @@ static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start)
       build_all_zonelists(pgdat, NULL);
       mutex_unlock(&zonelists_mutex);
   -    /*
-     * zone->managed_pages is set to an approximate value in
-     * free_area_init_core(), which will cause
-     * /sys/device/system/node/nodeX/meminfo has wrong data.
-     * So reset it to 0 before any memory is onlined.
-     */
-    reset_node_managed_pages(pgdat);
-
-    /*
-     * When memory is hot-added, all the memory is in offline state. So
-     * clear all zones' present_pages because they will be updated in
-     * online_pages() and offline_pages().
Quoted 9 lines

mm/memory_hotplug.c static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start) · line 1104

Quoted 6 lines
mm/memory_hotplug.c +0 -3
-     */
-    reset_node_present_pages(pgdat);
-
       return pgdat;
   }
 

.

Quoted 2 lines

.

.

#6 lore raw

Re: [PATCH 2/2] memory-hotplug: remove reset_node_managed_pages() and reset_node_managed_pages() in hotadd_new_pgdat()

Quoted 10 lines · Xishi Qiu

......

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
[ 2007.584000] On node 5 totalpages: 0
[ 2007.585000] Built 5 zonelists in Node order, mobility grouping on.  Total pages: 32588823
[ 2007.594000] Policy zone: Normal
[ 2007.598000] init_memory_mapping: [mem 0x60000000000-0x607ffffffff]

And also, if we merge this patch, /sys/devices/system/node/nodeX/meminfo will break.

trigger call trace?

Quoted 9 lines
Quoted 4 lines

No. There is no error output. But if you see /sys/devices/system/node/nodeX/meminfo, memory size will double because totalpages is calculated once here, and one more time when onlining memory.

Hi Tang,

Do you mean si_meminfo_node() -> val->totalram = managed_pages; will be added double? But my patch will keep it 0 in hotadd_new_pgdat(), so it will not be double, right?

Hi,

I mean this:

online_pages()
|--> zone->zone_pgdat->node_present_pages += onlined_pages;

It will be double.

Since meminfo data is retrieved from these kernel structures, /proc/meminfo will be broken.

Actually speaking, reset it when hot-adding memory is not a good idea. We should make the memory init code be suitable for both boot code and memory hot-plug code.

Thanks.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>