mm/memory_hotplug: fix memmap_on_memory sysfs value retrieval
Subsystems (3)
PATCH 1/1 mm/memory_hotplug: fix memmap_on_memory sysfs value retrieval
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.
--- mm/memory_hotplug.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
mm/memory_hotplug.c +5 -3
@@ -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 = {
Signature · 1 line
2.40.1
Quoted 26 lines · Sumanth Korikkar
The
set_memmap_mode()function stores the kernel parameter memmap mode as an integer. However, theget_memmap_mode()function utilizesparam_get_bool()to fetch the value as a boolean, leading to potential endianness issue. On Big-endian architectures, thememmap_on_memoryis 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_memoryparameter, 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 <[email protected]>Cc <[email protected]> # v6.6+Signed-off-by Sumanth Korikkar <[email protected]>--- mm/memory_hotplug.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)mm/memory_hotplug.c +0
-0@@ -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)
mm/memory_hotplug.c static int set_memmap_mode(const char *val, const struct kernel_param *kp) · line 109
Quoted 10 lines
mm/memory_hotplug.c +5
-3{ -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' ); }
I was wondering if we want to return "Y" instead of "force". But using force seems more consistent.
Signature · 3 lines
Cheers, David / dhildenb