From: William Theesfeld <william@theesfeld.net>
To: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
K Prateek Nayak <kprateek.nayak@amd.com>,
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 [thread overview]
Message-ID: <20260605182412.266367-1-william@theesfeld.net> (raw)
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 <william@theesfeld.net>
---
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
next reply other threads:[~2026-06-05 18:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-05 18:24 William Theesfeld [this message]
2026-06-15 15:19 ` Valentin Schneider
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260605182412.266367-1-william@theesfeld.net \
--to=william@theesfeld.net \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®