mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sched/topology: convert NUMA distance masks allocation to kcalloc()
@ 2026-06-05 18:24 William Theesfeld
  2026-06-15 15:19 ` Valentin Schneider
  0 siblings, 1 reply; 2+ messages in thread
From: William Theesfeld @ 2026-06-05 18:24 UTC (permalink / raw)
  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

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-15 15:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-05 18:24 [PATCH] sched/topology: convert NUMA distance masks allocation to kcalloc() William Theesfeld
2026-06-15 15:19 ` Valentin Schneider

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®