Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/mm_init: replace simple_strtoul with kstrtobool in set_hashdist

Use bool for 'hashdist' and replace simple_strtoul() with kstrtobool() for
parsing the 'hashdist=' boot parameter. Unlike simple_strtoul(), which
returns an unsigned long, kstrtobool() converts the string directly to
bool and avoids implicit casting.

Check the return value of kstrtobool() and reject invalid values. This
adds error handling while preserving behavior for existing values, and
removes use of the deprecated simple_strtoul() helper. The current code
silently sets 'hashdist = 0' if parsing fails, instead of leaving the
default value (HASHDIST_DEFAULT) unchanged.

Additionally, kstrtobool() accepts common boolean strings such as "on" and
"off".

Link: https://lkml.kernel.org/r/20251217110214.50807-1-thorsten.blum@linux.dev
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Thorsten Blum and committed by
Andrew Morton
84355caa a98ec863

+5 -8
+2 -2
include/linux/memblock.h
··· 598 598 */ 599 599 #ifdef CONFIG_NUMA 600 600 #define HASHDIST_DEFAULT IS_ENABLED(CONFIG_64BIT) 601 - extern int hashdist; /* Distribute hashes across NUMA nodes? */ 601 + extern bool hashdist; /* Distribute hashes across NUMA nodes? */ 602 602 #else 603 - #define hashdist (0) 603 + #define hashdist (false) 604 604 #endif 605 605 606 606 #ifdef CONFIG_MEMTEST
+3 -6
mm/mm_init.c
··· 646 646 return nid; 647 647 } 648 648 649 - int hashdist = HASHDIST_DEFAULT; 649 + bool hashdist = HASHDIST_DEFAULT; 650 650 651 651 static int __init set_hashdist(char *str) 652 652 { 653 - if (!str) 654 - return 0; 655 - hashdist = simple_strtoul(str, &str, 0); 656 - return 1; 653 + return kstrtobool(str, &hashdist) == 0; 657 654 } 658 655 __setup("hashdist=", set_hashdist); 659 656 660 657 static inline void fixup_hashdist(void) 661 658 { 662 659 if (num_node_state(N_MEMORY) == 1) 663 - hashdist = 0; 660 + hashdist = false; 664 661 } 665 662 #else 666 663 static inline void fixup_hashdist(void) {}