linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/memory_hotplug: fix memmap_on_memory sysfs value retrieval
@ 2024-01-10 14:01 Sumanth Korikkar
  2024-01-10 16:15 ` David Hildenbrand
  0 siblings, 1 reply; 2+ messages in thread
From: Sumanth Korikkar @ 2024-01-10 14:01 UTC (permalink / raw)
  To: linux-mm, Andrew Morton, Aneesh Kumar K.V, David Hildenbrand
  Cc: Oscar Salvador, Michal Hocko, Gerald Schaefer, Alexander Gordeev,
	Heiko Carstens, Vasily Gorbik, linux-s390, LKML

The set_memmap_mode() function stores the kernel parameter memmap mode
as an integer. However, the get_memmap_mode() function utilizes
param_get_bool() to fetch the value as a boolean, leading to potential
endianness issue. On Big-endian architectures, the memmap_on_memory is
consistently displayed as 'N' regardless of its actual status.

To address this endianness problem, the solution involves obtaining the
mode as an integer. This adjustment ensures the proper display of the
memmap_on_memory parameter, presenting it as one of the following
options: Force, Y, or N.

Fixes: 2d1f649c7c08 ("mm/memory_hotplug: support memmap_on_memory when memmap is not aligned to pageblocks")
Suggested-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Cc: <stable@vger.kernel.org> # v6.6+
Signed-off-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
---
 mm/memory_hotplug.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index b944e8bf1911..707027f69150 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -101,9 +101,11 @@ static int set_memmap_mode(const char *val, const struct kernel_param *kp)
 
 static int get_memmap_mode(char *buffer, const struct kernel_param *kp)
 {
-	if (*((int *)kp->arg) == MEMMAP_ON_MEMORY_FORCE)
-		return sprintf(buffer,  "force\n");
-	return param_get_bool(buffer, kp);
+	int mode = *((int *)kp->arg);
+
+	if (mode == MEMMAP_ON_MEMORY_FORCE)
+		return sprintf(buffer, "force\n");
+	return sprintf(buffer, "%c\n", mode ? 'Y' : 'N');
 }
 
 static const struct kernel_param_ops memmap_mode_ops = {
-- 
2.40.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-10 16:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-10 14:01 [PATCH] mm/memory_hotplug: fix memmap_on_memory sysfs value retrieval Sumanth Korikkar
2024-01-10 16:15 ` David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox