From nobody Tue May 16 04:11:01 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QL2ps73MHz4BVTn; Tue, 16 May 2023 04:11:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QL2ps4dF5z3vcV; Tue, 16 May 2023 04:11:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1684210261; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4RcbBKfPWi6LfGAe+Rfgfiuz4EGNl3WrcgoeHypKfqM=; b=y2uUW2YYbpceFifedH3wUUNFfo+AcjthaaEhUyulOMUKU5IYPyMGc5+ISwLRgbOJsnBqQF HJo2wnwBb9LQMcswZwMW1Wkpe+b24Ox4ZgnBoLhLwU91VkOhR8MqgG7UUiTGlKqgPuwitP PC4irm6zg3Jfj3sPsy20IM48EjuG4g0A1U6iCVzNpOGwWYGhIANRC4Xm00Rkz7GbEDoRcx fwYGesFcxMPPkLZ0VuUF6g/1YowKCOsmSI3dT6ZB8fpmlqriEKX+QVeEbdNXJwknnAGGRH N2zFknVgFfk6Y/FVy0r19JDL0wm5Yb74ZXaK2gXkgzk8IT0OZDAdfXprFrgXSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1684210261; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4RcbBKfPWi6LfGAe+Rfgfiuz4EGNl3WrcgoeHypKfqM=; b=hlkgFNFovq+ErDmbesT0gfQLpe6zPbCWmKRYSC/cpBLFYL6JFXM8VjOVMv1ghxIf9W3oGu BaDCx2XMD8fkmE/x2wyRpW/GG+1XM/fFMH82HKp7t8exupR5sy6yC63JEUP0OSoxkBa94A JkTBzl61d/pOdW+peY2/VVZileTJYyY3Th4bvIWi3JMxxyVaFb+ZgvKxNPAhsceh+8KoN0 MRqgd7MZ+ZU72jjqCaStJsvgvg4EZyJknQXBiPxSJR4JC8RnEB5GofKbpTVSxHapWhPTF2 46s3cAHKfZFIQ/TW3SbkcDsYmPwCFTY8yyk5uJR4rIFDtmmKmWZ4HqS/ucvsjg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1684210261; a=rsa-sha256; cv=none; b=UM4EdHgsCbb6Cr3u+3qyDT4eYoM8ecQo4+CielSzwjNugVAtVvuoPWMFBLIdybFWDpleC6 IAtFaZ7E6udeb9rrlp1V4xge+/UPrgtdGAjF8s4DacOoVWBPb0fzu/CyTHhkWZieBFh8mr J5hKrHOgadDi5DGoJ5Ube9FCNe94M+5Uo0oKM1qXtikZuVi2GUoN+Uq0jQtJ/tWCBd1NXa tFWzMT83urAuEcsUpGoxWFAl/bH9u8x9ndg6VHvRPYKLOhMw1+s9gTGd2pkMY4TRVH7zJP HEcU/Vn/bymn5YPxuo0R6gfpFZbxaYiCnaIx+4cMg8wbfQ6+R1gpbjO4Vjx7uw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QL2ps3V2Tz17Ft; Tue, 16 May 2023 04:11:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 34G4B1tS001975; Tue, 16 May 2023 04:11:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34G4B1fQ001974; Tue, 16 May 2023 04:11:01 GMT (envelope-from git) Date: Tue, 16 May 2023 04:11:01 GMT Message-Id: <202305160411.34G4B1fQ001974@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 5fdd2bfef42c - stable/13 - smp_topo: dynamically allocate group array List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 5fdd2bfef42c4bae197c56051c2066e499c43e4d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=5fdd2bfef42c4bae197c56051c2066e499c43e4d commit 5fdd2bfef42c4bae197c56051c2066e499c43e4d Author: Konstantin Belousov AuthorDate: 2023-05-05 20:24:22 +0000 Commit: Konstantin Belousov CommitDate: 2023-05-16 04:03:37 +0000 smp_topo: dynamically allocate group array (cherry picked from commit 9801e7c275f6ec42a44b98a2e2e1a8ac4674a096) --- sys/kern/subr_smp.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index 401d54277669..0ecc13251632 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -630,8 +630,6 @@ smp_rendezvous(void (* setup_func)(void *), smp_rendezvous_cpus(all_cpus, setup_func, action_func, teardown_func, arg); } -static struct cpu_group group[MAXCPU * MAX_CACHE_LEVELS + 1]; - static void smp_topo_fill(struct cpu_group *cg) { @@ -713,9 +711,14 @@ smp_topo(void) struct cpu_group * smp_topo_alloc(u_int count) { + static struct cpu_group *group = NULL; static u_int index; u_int curr; + if (group == NULL) { + group = mallocarray((mp_maxid + 1) * MAX_CACHE_LEVELS + 1, + sizeof(*group), M_DEVBUF, M_WAITOK | M_ZERO); + } curr = index; index += count; return (&group[curr]); @@ -726,7 +729,7 @@ smp_topo_none(void) { struct cpu_group *top; - top = &group[0]; + top = smp_topo_alloc(1); top->cg_parent = NULL; top->cg_child = NULL; top->cg_mask = all_cpus; @@ -780,9 +783,9 @@ smp_topo_1level(int share, int count, int flags) int i; cpu = 0; - top = &group[0]; + top = smp_topo_alloc(1); packages = mp_ncpus / count; - top->cg_child = child = &group[1]; + top->cg_child = child = top + 1; top->cg_level = CG_SHARE_NONE; for (i = 0; i < packages; i++, child++) cpu = smp_topo_addleaf(top, child, share, count, flags, cpu); @@ -801,8 +804,8 @@ smp_topo_2level(int l2share, int l2count, int l1share, int l1count, int j; cpu = 0; - top = &group[0]; - l2g = &group[1]; + top = smp_topo_alloc(1); + l2g = top + 1; top->cg_child = l2g; top->cg_level = CG_SHARE_NONE; top->cg_children = mp_ncpus / (l2count * l1count);