From 361c8f75a61832d9aa3dd4c589a0220f3467466f Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Tue, 9 May 2023 18:08:22 +0300 Subject: [PATCH] smp_topo(): correct allocation sizes for trivial topologies This patch should not modify the correctness, only the clarity. Requested and reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D39981 --- sys/kern/subr_smp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index 5a9aeb5ab04a..5a1013dad65f 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -790,8 +790,8 @@ smp_topo_1level(int share, int count, int flags) int i; cpu = 0; - top = smp_topo_alloc(1); packages = mp_ncpus / count; + top = smp_topo_alloc(1 + packages); top->cg_child = child = top + 1; top->cg_level = CG_SHARE_NONE; for (i = 0; i < packages; i++, child++) @@ -811,7 +811,8 @@ smp_topo_2level(int l2share, int l2count, int l1share, int l1count, int j; cpu = 0; - top = smp_topo_alloc(1); + top = smp_topo_alloc(1 + mp_ncpus / (l2count * l1count) + + mp_ncpus / l1count); l2g = top + 1; top->cg_child = l2g; top->cg_level = CG_SHARE_NONE;