Re: [PATCH] mm/mm_init: Replace simple_strtoul with kstrtobool in set_hashdist

From: Matthew Wilcox

Date: Thu Dec 18 2025 - 15:52:51 EST


On Wed, Dec 17, 2025 at 12:02:13PM +0100, Thorsten Blum wrote:
> 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".
>
> Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>

Reviewed-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>