Skip to contentSkip to conversation

mm/hotplug: only free wait_table if it's allocated by vmalloc

PATCH In review Jianguo Wu 3 participants 5 messages Mar 22, 2013 – Mar 25, 2013

Subsystems (2)
lore
Share & tools
lore

Jianguo Wu

author
#0 lore raw

PATCH 1/1 mm/hotplug: only free wait_table if it's allocated by vmalloc

zone->wait_table may be allocated from bootmem, it can not be freed.

Cc Andrew Morton <[email protected]>
Cc Wen Congyang <[email protected]>
Cc Tang Chen <[email protected]>
Cc Jiang Liu <[email protected]>
---
 mm/memory_hotplug.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
mm/memory_hotplug.c +5 -1
index 07b6263..91ed7cd 100644
@@ -1779,7 +1779,11 @@ void try_offline_node(int nid)
 	for (i = 0; i < MAX_NR_ZONES; i++) {
 		struct zone *zone = pgdat->node_zones + i;
 
-		if (zone->wait_table)
+		/*
+		 * wait_table may be allocated from boot memory,
+		 * here only free if it's allocated by vmalloc.
+		 */
+		if (is_vmalloc_addr(zone->wait_table))
 			vfree(zone->wait_table);
 	}
 
Signature · 8 lines
1.7.6.1


--
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>
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Jianguo Wu

zone->wait_table may be allocated from bootmem, it can not be freed.

Cc Andrew Morton<[email protected]>
Cc Wen Congyang<[email protected]>
Cc Tang Chen<[email protected]>
Cc Jiang Liu<[email protected]>
---
  mm/memory_hotplug.c |    6 +++++-
  1 files changed, 5 insertions(+), 1 deletions(-)
mm/memory_hotplug.c +0 -0
index 07b6263..91ed7cd 100644

mm/memory_hotplug.c void try_offline_node(int nid) · line 1787

Quoted 10 lines
mm/memory_hotplug.c +5 -1
@@ -1779,7 +1779,11 @@ void try_offline_node(int nid)
  	for (i = 0; i<  MAX_NR_ZONES; i++) {
  		struct zone *zone = pgdat->node_zones + i;
 
-		if (zone->wait_table)
+		/*
+		 * wait_table may be allocated from boot memory,
+		 * here only free if it's allocated by vmalloc.
+		 */
+		if (is_vmalloc_addr(zone->wait_table))
  			vfree(zone->wait_table);

FYI, I'm trying add a flag member into memblock to mark memory whose life cycle is the same as a node. I think maybe this flag could be used to free this kind of memory from bootmem.

Thanks. :)

mm/memory_hotplug.c void try_offline_node(int nid) · line 1789

Quoted 2 lines
mm/memory_hotplug.c +0 -0
  	}
 

--
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>

#2 lore raw

I have done a work to associate a tag with each memblock, may be that could be reused.

Quoted 31 lines · Tang Chen
Quoted 17 lines · Jianguo Wu

zone->wait_table may be allocated from bootmem, it can not be freed.

Cc Andrew Morton<[email protected]>
Cc Wen Congyang<[email protected]>
Cc Tang Chen<[email protected]>
Cc Jiang Liu<[email protected]>
---
  mm/memory_hotplug.c |    6 +++++-
  1 files changed, 5 insertions(+), 1 deletions(-)
mm/memory_hotplug.c +0 -0
index 07b6263..91ed7cd 100644

mm/memory_hotplug.c void try_offline_node(int nid) · line 1787

Quoted 10 lines
mm/memory_hotplug.c +5 -1
@@ -1779,7 +1779,11 @@ void try_offline_node(int nid)
      for (i = 0; i<  MAX_NR_ZONES; i++) {
          struct zone *zone = pgdat->node_zones + i;
 
-        if (zone->wait_table)
+        /*
+         * wait_table may be allocated from boot memory,
+         * here only free if it's allocated by vmalloc.
+         */
+        if (is_vmalloc_addr(zone->wait_table))
              vfree(zone->wait_table);
Quoted 11 lines

FYI, I'm trying add a flag member into memblock to mark memory whose life cycle is the same as a node. I think maybe this flag could be used to free this kind of memory from bootmem.

Thanks. :)

Quoted 2 lines
mm/memory_hotplug.c +0 -0
      }
 

--
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>

#3 lore raw
Quoted 2 lines · Jiang Liu

I have done a work to associate a tag with each memblock, may be that could be reused.

Hi Liu,

Yes, the CONFIG_HAVE_MEMBLOCK_TAG patch, I saw that before. :)

And it may have the following difference,
1) It is a flag, not a tag, which means a range may have several different attributes.
2) Mark node-lify-cycle data, and put it on local node, and free it when hot-removing.
3) Mark and reserve movable memory, as you did. :)

I'll try to find as much code that can be reused as I can. :)

Thanks for reminding me this. :)

Thanks. :)

Quoted 37 lines · Tang Chen
Quoted 35 lines · Jianguo Wu
Quoted 17 lines

zone->wait_table may be allocated from bootmem, it can not be freed.

Cc Andrew Morton<[email protected]>
Cc Wen Congyang<[email protected]>
Cc Tang Chen<[email protected]>
Cc Jiang Liu<[email protected]>
---
   mm/memory_hotplug.c |    6 +++++-
   1 files changed, 5 insertions(+), 1 deletions(-)
mm/memory_hotplug.c +0 -0
index 07b6263..91ed7cd 100644

mm/memory_hotplug.c void try_offline_node(int nid) · line 1787

Quoted 10 lines
mm/memory_hotplug.c +5 -1
@@ -1779,7 +1779,11 @@ void try_offline_node(int nid)
       for (i = 0; i<   MAX_NR_ZONES; i++) {
           struct zone *zone = pgdat->node_zones + i;
 
-        if (zone->wait_table)
+        /*
+         * wait_table may be allocated from boot memory,
+         * here only free if it's allocated by vmalloc.
+         */
+        if (is_vmalloc_addr(zone->wait_table))
               vfree(zone->wait_table);

FYI, I'm trying add a flag member into memblock to mark memory whose life cycle is the same as a node. I think maybe this flag could be used to free this kind of memory from bootmem.

Quoted 10 lines
Quoted 7 lines

Thanks. :)

Quoted 2 lines
mm/memory_hotplug.c +0 -0
       }
 

--
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>

author
#4 lore raw
In reply to Tang Chen
Quoted 31 lines · Tang Chen
Quoted 17 lines · Jianguo Wu

zone->wait_table may be allocated from bootmem, it can not be freed.

Cc Andrew Morton<[email protected]>
Cc Wen Congyang<[email protected]>
Cc Tang Chen<[email protected]>
Cc Jiang Liu<[email protected]>
---
  mm/memory_hotplug.c |    6 +++++-
  1 files changed, 5 insertions(+), 1 deletions(-)
mm/memory_hotplug.c +0 -0
index 07b6263..91ed7cd 100644

mm/memory_hotplug.c void try_offline_node(int nid) · line 1787

Quoted 10 lines
mm/memory_hotplug.c +5 -1
@@ -1779,7 +1779,11 @@ void try_offline_node(int nid)
      for (i = 0; i<  MAX_NR_ZONES; i++) {
          struct zone *zone = pgdat->node_zones + i;
 
-        if (zone->wait_table)
+        /*
+         * wait_table may be allocated from boot memory,
+         * here only free if it's allocated by vmalloc.
+         */
+        if (is_vmalloc_addr(zone->wait_table))
              vfree(zone->wait_table);
Quoted 3 lines

FYI, I'm trying add a flag member into memblock to mark memory whose life cycle is the same as a node. I think maybe this flag could be used to free this kind of memory from bootmem.

And only the bootmem is aligned to PAGE_SIZE, I think.

Quoted 14 lines

Thanks. :)

Quoted 2 lines
mm/memory_hotplug.c +0 -0
      }
 
Signature · 4 lines
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>

--
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>