[PATCH] memory hotplug disable boot option

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Nathan Fontenot
Date: Thursday, June 24, 2010 - 6:06 pm

Proposed patch to disable memory hotplug via a boot option,
mem_hotplug=[on|off].  The patch only disables memory hotplug in that it 
prevents the creation of the memory sysfs directories for memory sections.

This patch is meant to help alleviate very long boot times on systems with
large memory (1+ TB) and many memory sections (10's of thousands).

Signed-off-by: Nathan Fontenot <nfont@austin.ibm.com>

---
 drivers/base/memory.c  |   33 +++++++++++++++++++++++++++++++++
 drivers/base/node.c    |    3 +++
 include/linux/memory.h |    2 ++
 3 files changed, 38 insertions(+)

Index: linux-2.6/drivers/base/memory.c
===================================================================
--- linux-2.6.orig/drivers/base/memory.c	2010-06-23 15:07:03.000000000 -0500
+++ linux-2.6/drivers/base/memory.c	2010-06-24 18:46:52.000000000 -0500
@@ -29,6 +29,24 @@
 
 #define MEMORY_CLASS_NAME	"memory"
 
+static int mem_hp_enabled __read_mostly = 1;
+
+static int __setup_memory_hotplug(char *option)
+{
+	if (!strcmp(option, "off"))
+		mem_hp_enabled = 0;
+	else if (!strcmp(option, "on"))
+		mem_hp_enabled = 1;
+
+	return 1;
+}
+__setup("mem_hotplug=", __setup_memory_hotplug);
+
+int memory_hotplug_enabled(void)
+{
+	return mem_hp_enabled;
+}
+
 static struct sysdev_class memory_sysdev_class = {
 	.name = MEMORY_CLASS_NAME,
 };
@@ -320,6 +338,9 @@
 
 static int block_size_init(void)
 {
+	if (!memory_hotplug_enabled())
+		return 0;
+
 	return sysfs_create_file(&memory_sysdev_class.kset.kobj,
 				&attr_block_size_bytes.attr);
 }
@@ -442,6 +463,9 @@
 	unsigned long start_pfn;
 	int ret = 0;
 
+	if (!memory_hotplug_enabled())
+		return 0;
+
 	if (!mem)
 		return -ENOMEM;
 
@@ -483,6 +507,9 @@
 	struct memory_block *mem;
 	char name[sizeof(MEMORY_CLASS_NAME) + 9 + 1];
 
+	if (!memory_hotplug_enabled())
+		return NULL;
+
 	/*
 	 * This only works because we know that section == sysdev->id
 	 * slightly redundant with sysdev_register()
@@ -504,6 +531,9 @@
 {
 	struct memory_block *mem;
 
+	if (!memory_hotplug_enabled())
+		return 0;
+
 	mem = find_memory_block(section);
 	unregister_mem_sect_under_nodes(mem);
 	mem_remove_simple_file(mem, phys_index);
@@ -541,6 +571,9 @@
 	int ret;
 	int err;
 
+	if (!memory_hotplug_enabled())
+		return 0;
+
 	memory_sysdev_class.kset.uevent_ops = &memory_uevent_ops;
 	ret = sysdev_class_register(&memory_sysdev_class);
 	if (ret)
Index: linux-2.6/drivers/base/node.c
===================================================================
--- linux-2.6.orig/drivers/base/node.c	2010-06-23 15:07:03.000000000 -0500
+++ linux-2.6/drivers/base/node.c	2010-06-24 13:05:55.000000000 -0500
@@ -411,6 +411,9 @@
 	unsigned long pfn;
 	int err = 0;
 
+	if (!memory_hotplug_enabled())
+		return 0;
+
 	for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) {
 		unsigned long section_nr = pfn_to_section_nr(pfn);
 		struct mem_section *mem_sect;
Index: linux-2.6/include/linux/memory.h
===================================================================
--- linux-2.6.orig/include/linux/memory.h	2010-06-23 15:07:24.000000000 -0500
+++ linux-2.6/include/linux/memory.h	2010-06-24 13:06:25.000000000 -0500
@@ -128,6 +128,8 @@
 #define hotplug_memory_notifier(fn, pri) do { } while (0)
 #endif
 
+extern int memory_hotplug_enabled(void);
+
 /*
  * 'struct memory_accessor' is a generic interface to provide
  * in-kernel access to persistent memory such as i2c or SPI EEPROMs
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] memory hotplug disable boot option, Nathan Fontenot, (Thu Jun 24, 6:06 pm)
Re: [PATCH] memory hotplug disable boot option, KOSAKI Motohiro, (Thu Jun 24, 7:04 pm)
Re: [PATCH] memory hotplug disable boot option, Andi Kleen, (Fri Jun 25, 2:19 am)
Re: [PATCH] memory hotplug disable boot option, Nathan Fontenot, (Fri Jun 25, 7:51 am)
Re: [PATCH] memory hotplug disable boot option, Andi Kleen, (Fri Jun 25, 7:56 am)
Re: [PATCH] memory hotplug disable boot option, Nathan Fontenot, (Fri Jun 25, 8:21 am)
Re: [PATCH] memory hotplug disable boot option, Andi Kleen, (Fri Jun 25, 8:28 am)
Re: [PATCH] memory hotplug disable boot option, Nathan Fontenot, (Fri Jun 25, 9:00 am)
Re: [PATCH] memory hotplug disable boot option, KOSAKI Motohiro, (Sun Jun 27, 7:20 pm)
Re: [PATCH] memory hotplug disable boot option, Eric W. Biederman, (Sun Jun 27, 9:15 pm)
Re: [PATCH] memory hotplug disable boot option, Andi Kleen, (Mon Jun 28, 7:16 am)
Re: [PATCH] memory hotplug disable boot option, Greg KH, (Mon Jun 28, 8:02 am)
Re: [PATCH] memory hotplug disable boot option, Nathan Fontenot, (Mon Jun 28, 8:37 am)
Re: [PATCH] memory hotplug disable boot option, Greg KH, (Mon Jun 28, 8:44 am)
Re: [PATCH] memory hotplug disable boot option, Eric W. Biederman, (Mon Jun 28, 12:43 pm)
Re: [PATCH] memory hotplug disable boot option, Dave Hansen, (Mon Jun 28, 5:04 pm)
Re: [PATCH] memory hotplug disable boot option, KOSAKI Motohiro, (Mon Jun 28, 7:56 pm)
Re: [PATCH] memory hotplug disable boot option, Nathan Fontenot, (Tue Jun 29, 8:38 am)
Re: [PATCH] memory hotplug disable boot option, Dave Hansen, (Tue Jun 29, 9:03 am)
Re: [PATCH] memory hotplug disable boot option, Greg KH, (Tue Jun 29, 11:04 am)
Re: [PATCH] memory hotplug disable boot option, KOSAKI Motohiro, (Tue Jun 29, 5:00 pm)
Re: [PATCH] memory hotplug disable boot option, KAMEZAWA Hiroyuki, (Tue Jun 29, 5:32 pm)
Re: [PATCH] memory hotplug disable boot option, Greg KH, (Wed Jun 30, 8:47 am)
Re: [PATCH] memory hotplug disable boot option, KAMEZAWA Hiroyuki, (Wed Jun 30, 5:31 pm)
Re: [PATCH] memory hotplug disable boot option, Nathan Fontenot, (Wed Jun 30, 8:17 pm)
Re: [PATCH] memory hotplug disable boot option, KAMEZAWA Hiroyuki, (Wed Jun 30, 8:30 pm)
Re: [PATCH] memory hotplug disable boot option, KAMEZAWA Hiroyuki, (Wed Jun 30, 10:15 pm)
Re: [PATCH] memory hotplug disable boot option, Dave Hansen, (Thu Jul 1, 6:23 am)
Re: [PATCH] memory hotplug disable boot option, Greg KH, (Thu Jul 1, 4:26 pm)
Re: [PATCH] memory hotplug disable boot option, Greg KH, (Thu Jul 1, 4:28 pm)
Re: [PATCH] memory hotplug disable boot option, KAMEZAWA Hiroyuki, (Thu Jul 1, 10:50 pm)
Re: [PATCH] memory hotplug disable boot option, Nathan Fontenot, (Tue Jul 6, 8:20 am)
Re: [PATCH] memory hotplug disable boot option, Dave Hansen, (Tue Jul 6, 8:33 am)
Re: [PATCH] memory hotplug disable boot option, Nathan Fontenot, (Tue Jul 6, 8:47 am)