From nobody Sun Feb 8 15:59:13 2026 Received: from out-186.mta0.migadu.com (out-186.mta0.migadu.com [91.218.175.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 055E433F8CC for ; Wed, 17 Dec 2025 11:02:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.186 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765969360; cv=none; b=KKqx/X0ioZkIgNyyuyJFRX7MhKmatfbrUkksXO/42UaZwJbRa1HPQki0AbTNV92UWSzl++gxQUQeZr0kZlfNODSvk64yX2LkhrGtb5etzB4+1ibKLdr3AdbYV8chQZtoWXNJZSdNDHE7cmq8Vi4L+7CWRsEnLy6sqGroxOlxK9k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765969360; c=relaxed/simple; bh=C+mcfvs4nLQpUviUBJz365+U0nC23pGXIwy5ngEDv38=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=m6zxITKd8eo3x5QS8NKeEwmvJ8HDUMTyz0SOXbWo53nqgQGuMgs3ZaAr7aTouruPUcP14EAxdl3S/E1GoKzyfZZI2Fr6qGDesc40Nm/SBDDnHUsKKBwbZqjVsSpmO/AmMA1GXpFP9Qr9bRLM2ibzwsPDtEXgwVl+hlbyjPCbfv4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=EBXbwAnL; arc=none smtp.client-ip=91.218.175.186 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="EBXbwAnL" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1765969351; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ONjuWOHsXmlkvlW3RDBd2vPB9+75EpOLXx0cs86qt8k=; b=EBXbwAnLc2PPFeFic5WMslNkC7WpjI2H7ovsoeM0Ry2nDQVgK4dxdr0MQzkybJhW/KKXdx NBCLwnp2WlzFW8hJoZCaJIv+mRCcSmDQ7vsEDBG8bYHhpvZ1xZW5NSbFLiqN4vBYA4qfsl thFK0v6chablEY8GXNZ2OjSY8N9vNHE= From: Thorsten Blum To: Mike Rapoport , Andrew Morton Cc: Thorsten Blum , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm/mm_init: Replace simple_strtoul with kstrtobool in set_hashdist Date: Wed, 17 Dec 2025 12:02:13 +0100 Message-ID: <20251217110214.50807-1-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Use bool for 'hashdist' and replace simple_strtoul() with kstrtobool() for parsing the 'hashdist=3D' 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 =3D 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 Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: Mike Rapoport (Microsoft) --- include/linux/memblock.h | 4 ++-- mm/mm_init.c | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 221118b5a16e..6ec5e9ac0699 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -598,9 +598,9 @@ extern void *alloc_large_system_hash(const char *tablen= ame, */ #ifdef CONFIG_NUMA #define HASHDIST_DEFAULT IS_ENABLED(CONFIG_64BIT) -extern int hashdist; /* Distribute hashes across NUMA nodes? */ +extern bool hashdist; /* Distribute hashes across NUMA nodes? */ #else -#define hashdist (0) +#define hashdist (false) #endif =20 #ifdef CONFIG_MEMTEST diff --git a/mm/mm_init.c b/mm/mm_init.c index fc2a6f1e518f..d86248566a56 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -646,21 +646,18 @@ int __meminit early_pfn_to_nid(unsigned long pfn) return nid; } =20 -int hashdist =3D HASHDIST_DEFAULT; +bool hashdist =3D HASHDIST_DEFAULT; =20 static int __init set_hashdist(char *str) { - if (!str) - return 0; - hashdist =3D simple_strtoul(str, &str, 0); - return 1; + return kstrtobool(str, &hashdist) =3D=3D 0; } __setup("hashdist=3D", set_hashdist); =20 static inline void fixup_hashdist(void) { if (num_node_state(N_MEMORY) =3D=3D 1) - hashdist =3D 0; + hashdist =3D false; } #else static inline void fixup_hashdist(void) {} --=20 Thorsten Blum GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4