[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241202082732.3959803-3-sumanthk@linux.ibm.com>
Date: Mon, 2 Dec 2024 09:27:30 +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 2/4] mm/memory_hotplug: Add memory block altmap sysfs attribute
Currently memmap_on_memory sysfs attribute can determine if the altmap
is supported in the entire system.
However, with CONFIG_RUNTIME_MEMORY_CONFIGURATION, user can dynamically
add or remove individual memory blocks with/without altmap support.
Hence, it is more beneficial to the user, if the altmap support can also
be represented per memory block.
lsmem output could look like the following:
RANGE SIZE STATE BLOCK ALTMAP
0x0000000000000000-0x000000007fffffff 2G online 0-7 0
0x0000000080000000-0x00000001ffffffff 6G online 8-31 0
0x0000000200000000-0x00000002ffffffff 4G offline 32-47 1
Reviewed-by: Gerald Schaefer <gerald.schaefer@...ux.ibm.com>
Signed-off-by: Sumanth Korikkar <sumanthk@...ux.ibm.com>
---
drivers/base/memory.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index f024444b3301..469adc7212fc 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -431,6 +431,14 @@ static ssize_t phys_device_show(struct device *dev,
arch_get_memory_phys_device(start_pfn));
}
+static ssize_t altmap_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct memory_block *mem = to_memory_block(dev);
+
+ return sysfs_emit(buf, "%u\n", mem->altmap ? 1 : 0);
+}
+
#ifdef CONFIG_MEMORY_HOTREMOVE
static int print_allowed_zone(char *buf, int len, int nid,
struct memory_group *group,
@@ -492,6 +500,7 @@ static DEVICE_ATTR_RO(phys_index);
static DEVICE_ATTR_RW(state);
static DEVICE_ATTR_RO(phys_device);
static DEVICE_ATTR_RO(removable);
+static DEVICE_ATTR_RO(altmap);
/*
* Show the memory block size (shared by all memory blocks).
@@ -785,6 +794,7 @@ static struct attribute *memory_memblk_attrs[] = {
#ifdef CONFIG_MEMORY_HOTREMOVE
&dev_attr_valid_zones.attr,
#endif
+ &dev_attr_altmap.attr,
NULL
};
--
2.45.2
Powered by blists - more mailing lists