lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1374701399-30842-1-git-send-email-kys@microsoft.com>
Date:	Wed, 24 Jul 2013 14:29:58 -0700
From:	"K. Y. Srinivasan" <kys@...rosoft.com>
To:	gregkh@...uxfoundation.org, linux-kernel@...r.kernel.org,
	devel@...uxdriverproject.org, olaf@...fle.de, apw@...onical.com,
	andi@...stfloor.org, akpm@...ux-foundation.org, linux-mm@...ck.org,
	kamezawa.hiroyuki@...il.com, mhocko@...e.cz, hannes@...xchg.org,
	yinghan@...gle.com, dave@...1.net
Cc:	"K. Y. Srinivasan" <kys@...rosoft.com>
Subject: [PATCH 1/2] Drivers: base: memory: Export functionality for "in kernel" onlining of memory

The current machinery for hot-adding memory requires having user
level to bring the memory segments online. Export the necessary functionality
to bring the memory segment online without involving user space code.

Signed-off-by: K. Y. Srinivasan <kys@...rosoft.com>
---
 drivers/base/memory.c  |   35 +++++++++++++++++++++++++++++++++++
 include/linux/memory.h |    5 +++++
 2 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 2b7813e..a7140b3 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -541,6 +541,41 @@ struct memory_block *find_memory_block(struct mem_section *section)
 	return find_memory_block_hinted(section, NULL);
 }
 
+/*
+ * Given the start pfn of a memory block; bring the memory
+ * block online. This API would be useful for drivers that may
+ * want to bring "online" the memory that has been hot-added.
+ */
+
+int online_memory_block(unsigned long start_pfn)
+{
+	struct mem_section *cur_section;
+	struct memory_block *cur_memory_block;
+	int ret_val = -EINVAL;
+
+	cur_section = __pfn_to_section(start_pfn);
+
+	if (!valid_section(cur_section))
+		return ret_val;
+
+	mutex_lock(&mem_sysfs_mutex);
+	cur_memory_block = find_memory_block(cur_section);
+
+	if (!cur_memory_block) {
+		mutex_unlock(&mem_sysfs_mutex);
+		return ret_val;
+	}
+
+	lock_device_hotplug();
+	ret_val = memory_block_change_state(cur_memory_block, MEM_ONLINE,
+						MEM_OFFLINE, ONLINE_KEEP);
+	unlock_device_hotplug();
+	mutex_unlock(&mem_sysfs_mutex);
+
+	return ret_val;
+}
+EXPORT_SYMBOL_GPL(online_memory_block);
+
 static struct attribute *memory_memblk_attrs[] = {
 	&dev_attr_phys_index.attr,
 	&dev_attr_end_phys_index.attr,
diff --git a/include/linux/memory.h b/include/linux/memory.h
index 85c31a8..7d0d2a6 100644
--- a/include/linux/memory.h
+++ b/include/linux/memory.h
@@ -109,12 +109,17 @@ static inline int memory_isolate_notify(unsigned long val, void *v)
 {
 	return 0;
 }
+static inline int online_memory_block(unsigned long start_pfn)
+{
+	return 0;
+}
 #else
 extern int register_memory_notifier(struct notifier_block *nb);
 extern void unregister_memory_notifier(struct notifier_block *nb);
 extern int register_memory_isolate_notifier(struct notifier_block *nb);
 extern void unregister_memory_isolate_notifier(struct notifier_block *nb);
 extern int register_new_memory(int, struct mem_section *);
+extern int online_memory_block(unsigned long start_pfn);
 #ifdef CONFIG_MEMORY_HOTREMOVE
 extern int unregister_memory_section(struct mem_section *);
 #endif
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ