From nobody Tue May 09 15:30:15 2023 X-Original-To: dev-commits-src-all@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 4QG2Cq5hpmz4BKDP; Tue, 9 May 2023 15:30:15 +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 4QG2Cq59Fvz3r80; Tue, 9 May 2023 15:30:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683646215; 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=93fZcNsltL2VswSpjQT05wCAA3WI5pVjNfiIkwUU4AY=; b=pIMYy8kJSht7RCiIeYj0VxTn2kshCtD0LiIkkF5+MTV/0AgATpo80sVCCxMuMGRrXCiJEm J0iM4cSQ8gcg3q8up7LXkaZyEvKE4qdqIGdN9R/JFd1cOYhDjNHRr7mPti5v7hIkoiItYc aip3okrmKIYwT2y5jm+vZ8ZOri9GYzi3NFjGnL6Pq9rFYx16sYZuCdJkh64tvv2iI8BhMX QjriNq4Zz+7x7wigkhBP3mvvO8o8s/6sPALT10kGBTA/1qPTFUGbCZYrJK0zJvF/ZUJJE8 fiaFm4IQB0OUewvTuiPYA7vIOX9+widg4wKWepYqfzx4ziDAV20W+pgh58j2Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683646215; 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=93fZcNsltL2VswSpjQT05wCAA3WI5pVjNfiIkwUU4AY=; b=UWjUQeG9jnJfXF4FdrixR3OER0M4MF1WPu8vOaa590kz26gJc4m5hqfaA9bndXq0D6+PJA vh71ujOkeIp3v31XTDdtVoY+XiSmkLQ7PAl0moEYP7Vb2iOlWUCPGmAsobFYviKllDqyxn nVcaGvq/EylUIOjvac9+S9S397TEOauCEbfFAmvH9hZVYI5KNQCc+k3WEBLyFtqS1YGb6z pXvVIwT6jEf1jMF+2xiztLzGfPSb2ntiUAVZat94ON/XjIZcZWfm7qpcMwlUcLm3tQqzSn tmjJNTaXU/kFiwIWWxD9kDcqBh/U36oBWXB13HCXZ2GGwVoYZcRowX8yJnPscA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1683646215; a=rsa-sha256; cv=none; b=Ov/ZxOq8vSKSq6tTZDRaRxUpaYF4+qxS1xb6FCFDNGOL8DxTk8aK6VZwybBfG5j0F/Pcn7 Jb1qLrjbLxyGIS62ONtw5wWkBPDXR/xYshW+9g7YX7PputbfW6MPIDMrgCdBkQLTHh6uSs ZDZQSdK48Jyp4aIOGlvJdHmd9TlNh4tFDWsB3N/Zsj3jU6Flhxijwfd2eoONDJri4UdjgF /LBjGfSAabtqal0RtTYyQQPIu2C09RHstaQIcQtwGK0H3QEwrjdjhwf9LtsJh3k5IBosae DkhzisjGApk5W7PLE2Egs61WcFFdXL61mulVdax7UxRc8UCiVNhd0tnP8xdx5g== 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 4QG2Cq3vTDzYPw; Tue, 9 May 2023 15:30:15 +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 349FUFFN022500; Tue, 9 May 2023 15:30:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 349FUFnb022497; Tue, 9 May 2023 15:30:15 GMT (envelope-from git) Date: Tue, 9 May 2023 15:30:15 GMT Message-Id: <202305091530.349FUFnb022497@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 9801e7c275f6 - main - smp_topo: dynamically allocate group array List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/main X-Git-Reftype: branch X-Git-Commit: 9801e7c275f6ec42a44b98a2e2e1a8ac4674a096 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=9801e7c275f6ec42a44b98a2e2e1a8ac4674a096 commit 9801e7c275f6ec42a44b98a2e2e1a8ac4674a096 Author: Konstantin Belousov AuthorDate: 2023-05-05 20:24:22 +0000 Commit: Konstantin Belousov CommitDate: 2023-05-09 15:30:07 +0000 smp_topo: dynamically allocate group array Limit its size to mp_maxid + 1 times MAX_CACHE_LEVELS instead MAXCPU. Allocate the array on a first call into smp_topo(9) functions, where the mp_maxid is already known. Make the array private to smp_topo_alloc(), assuming that the callers that allocate top-level group do it once. Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D39981 --- 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 745b1554371e..df82d948afb0 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);