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: <20241202082732.3959803-4-sumanthk@linux.ibm.com>
Date: Mon,  2 Dec 2024 09:27:31 +0100
From: Sumanth Korikkar <sumanthk@...ux.ibm.com>
To: David Hildenbrand <david@...hat.com>, linux-mm <linux-mm@...ck.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
        Oscar Salvador <osalvador@...e.de>,
        Gerald Schaefer <gerald.schaefer@...ux.ibm.com>,
        Heiko Carstens <hca@...ux.ibm.com>, Vasily Gorbik <gor@...ux.ibm.com>,
        Alexander Gordeev <agordeev@...ux.ibm.com>,
        linux-s390 <linux-s390@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Sumanth Korikkar <sumanthk@...ux.ibm.com>
Subject: [RFC PATCH 3/4] mm/memory_hotplug: Add max_configurable sysfs read attribute

Introduce /sys/devices/system/memory/max_configurable sysfs interface to
list maximum number of configurable memory blocks by the architecture.
Using this information, lsmem tool could possibly read memory blocks
/sys/devices/system/memory/memory[0-9]+ as configured and list rest of
the max_configurable count as deconfigured.

Arch can define max_configurable by overriding
arch_get_memory_max_configurable().

s390 usecase:
/sys/devices/system/memory/max_configurable would be online + standby
memory blocks count. The max_configurable attribute for s390 is
configured in the next patch.

x86 possible usecase:
max_configurable could be initially set to count of all online memory
blocks. Later, max_configurable can be updated whenever there is an
acpi event generation for hotplugged memory. Userspace application like
lsmem could possibly read memory blocks
/sys/devices/system/memory/memory[0-9]+ as configured and rest of the
max_configurable count as deconfigured.

Reviewed-by: Gerald Schaefer <gerald.schaefer@...ux.ibm.com>
Signed-off-by: Sumanth Korikkar <sumanthk@...ux.ibm.com>
---
 drivers/base/memory.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 469adc7212fc..3da83345b570 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -665,6 +665,15 @@ bool __weak arch_validate_memory_range(unsigned long long start,
 	return false;
 }
 
+/*
+ * Arch can override the function and return the number of maximum configurable
+ * memory.
+ */
+ssize_t __weak arch_get_memory_max_configurable(void)
+{
+	return 0;
+}
+
 /*
  * Format:
  * echo config_mode,memoryrange,altmap_mode >
@@ -759,6 +768,15 @@ static ssize_t configure_memory_store(struct device *dev,
 	return ret ? ret : count;
 }
 static DEVICE_ATTR_WO(configure_memory);
+
+/*
+ * Show the maximum number of configurable memory.
+ */
+static ssize_t max_configurable_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	return sysfs_emit(buf, "%lu\n", arch_get_memory_max_configurable());
+}
+static DEVICE_ATTR_RO(max_configurable);
 #endif /* CONFIG_RUNTIME_MEMORY_CONFIGURATION */
 
 /*
@@ -1075,6 +1093,7 @@ static struct attribute *memory_root_attrs[] = {
 #endif
 #ifdef CONFIG_RUNTIME_MEMORY_CONFIGURATION
 	&dev_attr_configure_memory.attr,
+	&dev_attr_max_configurable.attr,
 #endif
 	NULL
 };
-- 
2.45.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ