From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-43172.protonmail.ch (mail-43172.protonmail.ch [185.70.43.172]) (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 BF1E35464D for ; Fri, 5 Jun 2026 18:24:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.43.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780683864; cv=none; b=Ayiv6D/2Ks4D1e93pVudfSLPkpi/PU3Fr6aoSfcBwZwHdR0zvqLJFIV+G440Ve0/hifpnhGYURf30SU/t1yMY/S7hYNtZ0bkqJgbH+9/zZO/1/B4NVtDCqsQ6Mh40/e+qiR9oT0zW1x1+2hq41794fFP4dfvwdjiiPXnbYKAneM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780683864; c=relaxed/simple; bh=PUqP/qPSj/DhzF+1Jd0gWJYBn/8AiFS2Xc0jp1m32QQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=kH5fQMXp0z69s8wGOYFoUqJdTvTmXJQkYJi1mADN1bNU9z0eu1/2bFv7YoRss3kV9nDep1Dt9ViSRL30buxQduusvH6kpE4rtkFh3sNw+jqz5HEFR/E74Sj/KAYbESv3V3ZEUp4cPPoOJsK34QEY+b4GXlWGZjFe27l86Iaos+8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=theesfeld.net; spf=fail smtp.mailfrom=theesfeld.net; dkim=fail (0-bit key) header.d=theesfeld.net header.i=@theesfeld.net header.b=QqRmIMpg reason="key not found in DNS"; arc=none smtp.client-ip=185.70.43.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=theesfeld.net Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=theesfeld.net Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=theesfeld.net header.i=@theesfeld.net header.b="QqRmIMpg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=theesfeld.net; s=protonmail2; t=1780683858; x=1780943058; bh=imiJzo9clLKTXBj6/Zx+qrX6DX+v2n9fSGH/1h1ERww=; h=From:To:Cc:Subject:Date:Message-ID:From:To:Cc:Date:Subject: Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=QqRmIMpgWtijOxo89aI7vlN01Fwkb0Y5DnlfVk4D6plYo09Magty+ysvtbySgPO5A 3dkV7DA1A0SMARROmP6m+oac3qeW2WmJ/r3KAs0l2OKSmR8pU4l/lPOhTgn9XldiGG xo73Zs3MztzFMD8xYPJUwdrhJYRg70gfClrIzlsIHqH6n7ZJhFlrSlV0/LVOFQEsYs JRuRvGrT0S36tVp8PMnr2IsGHEM6nkV63y0vW4nxKT7s6urBtAgpHKxan3VwOQozw0 LBDJwEea0uQKz/nEPIqi6+czr+0EaJDqT7U442rT8Blabmw1M5AnD+pA6VHvtLqPnJ 0uNk7TMeJWtGw== X-Pm-Submission-Id: 4gX8wG0M6Gz2ScdK From: William Theesfeld To: Ingo Molnar Cc: Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , linux-kernel@vger.kernel.org Subject: [PATCH] sched/topology: convert NUMA distance masks allocation to kcalloc() Date: Fri, 5 Jun 2026 14:24:12 -0400 Message-ID: <20260605182412.266367-1-william@theesfeld.net> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit sched_init_numa() builds the per-level NUMA distance masks via an open-coded kzalloc(nr_node_ids * sizeof(void *), ...). Switch to kcalloc(), which carries the same zero-on-allocation semantics and adds the standard size_mul overflow check on the multiplication. nr_node_ids is bounded by MAX_NUMNODES at compile time, so the overflow check folds away in practice; the conversion is for consistency with the kernel-wide pattern and to keep kernel/sched/ free of the open-coded form. No functional change. Signed-off-by: William Theesfeld --- kernel/sched/topology.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 5847b83d9..bb900ae22 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -2083,7 +2083,7 @@ void sched_init_numa(int offline_node) * CPUs of nodes that are that many hops away from us. */ for (i = 0; i < nr_levels; i++) { - masks[i] = kzalloc(nr_node_ids * sizeof(void *), GFP_KERNEL); + masks[i] = kcalloc(nr_node_ids, sizeof(void *), GFP_KERNEL); if (!masks[i]) return; -- 2.54.0