Skip to content

Commit 6c95b6a

Browse files
committed
mm/memory_hotplug: fix memmap_on_memory sysfs value retrieval
JIRA: https://issues.redhat.com/browse/RHEL-23824 commit 1168413 Author: Sumanth Korikkar <sumanthk@linux.ibm.com> Date: Wed Jan 10 15:01:27 2024 +0100 mm/memory_hotplug: fix memmap_on_memory sysfs value retrieval set_memmap_mode() 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. Link: https://lkml.kernel.org/r/20240110140127.241451-1-sumanthk@linux.ibm.com Fixes: 2d1f649 ("mm/memory_hotplug: support memmap_on_memory when memmap is not aligned to pageblocks") Signed-off-by: Sumanth Korikkar <sumanthk@linux.ibm.com> Suggested-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com> Acked-by: David Hildenbrand <david@redhat.com> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: Michal Hocko <mhocko@suse.com> Cc: Oscar Salvador <osalvador@suse.de> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: <stable@vger.kernel.org> [6.6+] Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
1 parent 5283a1c commit 6c95b6a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

mm/memory_hotplug.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,11 @@ static int set_memmap_mode(const char *val, const struct kernel_param *kp)
102102

103103
static int get_memmap_mode(char *buffer, const struct kernel_param *kp)
104104
{
105-
if (*((int *)kp->arg) == MEMMAP_ON_MEMORY_FORCE)
106-
return sprintf(buffer, "force\n");
107-
return param_get_bool(buffer, kp);
105+
int mode = *((int *)kp->arg);
106+
107+
if (mode == MEMMAP_ON_MEMORY_FORCE)
108+
return sprintf(buffer, "force\n");
109+
return sprintf(buffer, "%c\n", mode ? 'Y' : 'N');
108110
}
109111

110112
static const struct kernel_param_ops memmap_mode_ops = {

0 commit comments

Comments
 (0)