linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Sumanth Korikkar <sumanthk@linux.ibm.com>
To: David Hildenbrand <david@redhat.com>, linux-mm <linux-mm@kvack.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Oscar Salvador <osalvador@suse.de>,
	Gerald Schaefer <gerald.schaefer@linux.ibm.com>,
	Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	linux-s390 <linux-s390@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Sumanth Korikkar <sumanthk@linux.ibm.com>
Subject: [RFC PATCH 3/4] mm/memory_hotplug: Add max_configurable sysfs read attribute
Date: Mon,  2 Dec 2024 09:27:31 +0100	[thread overview]
Message-ID: <20241202082732.3959803-4-sumanthk@linux.ibm.com> (raw)
In-Reply-To: <20241202082732.3959803-1-sumanthk@linux.ibm.com>

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@linux.ibm.com>
Signed-off-by: Sumanth Korikkar <sumanthk@linux.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



  parent reply	other threads:[~2024-12-05 15:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-02  8:27 [RFC PATCH 0/4] Support dynamic (de)configuration of memory Sumanth Korikkar
2024-12-02  8:27 ` [RFC PATCH 1/4] mm/memory_hotplug: Add interface for runtime " Sumanth Korikkar
2024-12-02 16:55   ` David Hildenbrand
2024-12-03 14:33     ` Sumanth Korikkar
2024-12-20 15:53       ` David Hildenbrand
2025-05-20 13:06         ` Sumanth Korikkar
2025-05-20 17:55           ` David Hildenbrand
2025-05-21 10:34             ` Sumanth Korikkar
2025-05-21 12:33               ` David Hildenbrand
2025-05-21 14:21                 ` Heiko Carstens
2025-05-21 14:25                   ` David Hildenbrand
2025-05-21 14:24                 ` Sumanth Korikkar
2024-12-02  8:27 ` [RFC PATCH 2/4] mm/memory_hotplug: Add memory block altmap sysfs attribute Sumanth Korikkar
2024-12-02  8:27 ` Sumanth Korikkar [this message]
2024-12-02  8:27 ` [RFC PATCH 4/4] s390/sclp: Add support for dynamic (de)configuration of memory Sumanth Korikkar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241202082732.3959803-4-sumanthk@linux.ibm.com \
    --to=sumanthk@linux.ibm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=gerald.schaefer@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=osalvador@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox