public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch -mm] mm: slab allocate memory section nodemask for large systems
@ 2009-11-18  0:19 David Rientjes
  2009-11-18 18:35 ` Gary Hade
  0 siblings, 1 reply; 9+ messages in thread
From: David Rientjes @ 2009-11-18  0:19 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Gary Hade, Badari Pulavarty, Alex Chiang, linux-kernel

Nodemasks should not be allocated on the stack for large systems (when it
is larger than 256 bytes) since there is a threat of overflow.

This patch causes the unregister_mem_sect_under_nodes() nodemask to be
allocated on the stack for smaller systems and be allocated by slab for
larger systems.

GFP_KERNEL is used since remove_memory_block() can block.

Cc: Gary Hade <garyhade@us.ibm.com>
Cc: Badari Pulavarty <pbadari@us.ibm.com>
Cc: Alex Chiang <achiang@hp.com>
Signed-off-by: David Rientjes <rientjes@google.com>
---
 drivers/base/node.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/base/node.c b/drivers/base/node.c
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -363,12 +363,16 @@ int register_mem_sect_under_node(struct memory_block *mem_blk, int nid)
 /* unregister memory section under all nodes that it spans */
 int unregister_mem_sect_under_nodes(struct memory_block *mem_blk)
 {
-	nodemask_t unlinked_nodes;
+	NODEMASK_ALLOC(nodemask_t, unlinked_nodes, GFP_KERNEL);
 	unsigned long pfn, sect_start_pfn, sect_end_pfn;
 
-	if (!mem_blk)
+	if (!mem_blk) {
+		NODEMASK_FREE(unlinked_nodes);
 		return -EFAULT;
-	nodes_clear(unlinked_nodes);
+	}
+	if (!unlinked_nodes)
+		return -ENOMEM;
+	nodes_clear(*unlinked_nodes);
 	sect_start_pfn = section_nr_to_pfn(mem_blk->phys_index);
 	sect_end_pfn = sect_start_pfn + PAGES_PER_SECTION - 1;
 	for (pfn = sect_start_pfn; pfn <= sect_end_pfn; pfn++) {
@@ -379,13 +383,14 @@ int unregister_mem_sect_under_nodes(struct memory_block *mem_blk)
 			continue;
 		if (!node_online(nid))
 			continue;
-		if (node_test_and_set(nid, unlinked_nodes))
+		if (node_test_and_set(nid, *unlinked_nodes))
 			continue;
 		sysfs_remove_link(&node_devices[nid].sysdev.kobj,
 			 kobject_name(&mem_blk->sysdev.kobj));
 		sysfs_remove_link(&mem_blk->sysdev.kobj,
 			 kobject_name(&node_devices[nid].sysdev.kobj));
 	}
+	NODEMASK_FREE(unlinked_nodes);
 	return 0;
 }
 

^ permalink raw reply	[flat|nested] 9+ messages in thread
* [PATCH v2 0/5] mm: modest useability enhancements for node sysfs attrs
@ 2009-10-22  4:15 Alex Chiang
  2009-10-22  4:15 ` [PATCH v2 1/5] mm: add numa node symlink for memory section in sysfs Alex Chiang
  0 siblings, 1 reply; 9+ messages in thread
From: Alex Chiang @ 2009-10-22  4:15 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel

This is v2 of the series.

The last patch in this series is dependent upon the documentation patch
series that I just sent out a few moments ago:

	http://thread.gmane.org/gmane.linux.kernel/905018

Thanks,
/ac


v1 -> v2: http://thread.gmane.org/gmane.linux.kernel.mm/40084/
	Address David Rientjes's comments
	- check return value of sysfs_create_link in register_cpu_under_node
	- do /not/ convert [un]register_cpu_under_node to return void, since
	  sparse starts whinging if you ignore sysfs_create_link()'s return
	  value and working around sparse makes the code ugly
	- adjust documentation

	Added S390 maintainers to cc: for patch [1/5] as per Kame-san's
	suggestion. S390 may map a memory section to more than one node,
	causing this series to break.

---

Alex Chiang (5):
      mm: add numa node symlink for memory section in sysfs
      mm: refactor register_cpu_under_node()
      mm: refactor unregister_cpu_under_node()
      mm: add numa node symlink for cpu devices in sysfs
      Documentation: ABI: /sys/devices/system/cpu/cpu#/node


 Documentation/ABI/testing/sysfs-devices-memory     |   14 ++++-
 Documentation/ABI/testing/sysfs-devices-system-cpu |   15 +++++
 Documentation/memory-hotplug.txt                   |   11 ++--
 drivers/base/node.c                                |   58 ++++++++++++++------
 4 files changed, 77 insertions(+), 21 deletions(-)


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-11-18 18:35 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-18  0:19 [patch -mm] mm: slab allocate memory section nodemask for large systems David Rientjes
2009-11-18 18:35 ` Gary Hade
  -- strict thread matches above, loose matches on Subject: below --
2009-10-22  4:15 [PATCH v2 0/5] mm: modest useability enhancements for node sysfs attrs Alex Chiang
2009-10-22  4:15 ` [PATCH v2 1/5] mm: add numa node symlink for memory section in sysfs Alex Chiang
2009-10-22 19:51   ` David Rientjes
2009-10-27 19:59     ` Alex Chiang
2009-10-27 21:27       ` David Rientjes
2009-10-28  8:31         ` Heiko Carstens
2009-10-28  9:03           ` David Rientjes
2009-10-28 18:39             ` Alex Chiang
2009-10-28 20:43               ` [patch -mm] mm: slab allocate memory section nodemask for large systems David Rientjes
2009-11-02 20:47                 ` Alex Chiang
2009-11-04  2:00                   ` David Rientjes
2009-11-10 20:51                   ` Andrew Morton
2009-11-10 20:55                     ` David Rientjes
2009-11-10 21:26                       ` Alex Chiang
2009-11-10 21:38                         ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox