Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 May 2023 04:11:02 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: f296166d7be4 - stable/13 - smp_topo(): make it idempotent
Message-ID:  <202305160411.34G4B2MC001994@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=f296166d7be49b6105105344980cd45079551a9e

commit f296166d7be49b6105105344980cd45079551a9e
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-05-07 18:37:42 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-05-16 04:03:37 +0000

    smp_topo(): make it idempotent
    
    (cherry picked from commit d0f67f97579f7b2febf29264b1874a95056dec06)
---
 sys/kern/subr_smp.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c
index 0ecc13251632..8d3e398d6b54 100644
--- a/sys/kern/subr_smp.c
+++ b/sys/kern/subr_smp.c
@@ -645,7 +645,14 @@ struct cpu_group *
 smp_topo(void)
 {
 	char cpusetbuf[CPUSETBUFSIZ], cpusetbuf2[CPUSETBUFSIZ];
-	struct cpu_group *top;
+	static struct cpu_group *top = NULL;
+
+	/*
+	 * The first call to smp_topo() is guaranteed to occur
+	 * during the kernel boot while we are still single-threaded.
+	 */
+	if (top != NULL)
+		return (top);
 
 	/*
 	 * Check for a fake topology request for debugging purposes.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202305160411.34G4B2MC001994>