Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern mi_cpu_init(): provide fake topology info for early...
details: https://anonhg.NetBSD.org/src/rev/b23e032d0479
branches: trunk
changeset: 968185:b23e032d0479
user: ad <ad%NetBSD.org@localhost>
date: Sun Jan 05 20:27:43 2020 +0000
description:
mi_cpu_init(): provide fake topology info for early boot.
diffstat:
sys/kern/subr_cpu.c | 40 +++++++++++++++++++++++++++-------------
1 files changed, 27 insertions(+), 13 deletions(-)
diffs (84 lines):
diff -r a237655460f0 -r b23e032d0479 sys/kern/subr_cpu.c
--- a/sys/kern/subr_cpu.c Sun Jan 05 20:26:56 2020 +0000
+++ b/sys/kern/subr_cpu.c Sun Jan 05 20:27:43 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_cpu.c,v 1.4 2020/01/02 01:31:17 ad Exp $ */
+/* $NetBSD: subr_cpu.c,v 1.5 2020/01/05 20:27:43 ad Exp $ */
/*-
* Copyright (c) 2007, 2008, 2009, 2010, 2012, 2019 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_cpu.c,v 1.4 2020/01/02 01:31:17 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_cpu.c,v 1.5 2020/01/05 20:27:43 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -71,6 +71,8 @@
#include <sys/kernel.h>
#include <sys/kmem.h>
+static void cpu_topology_fake1(struct cpu_info *);
+
kmutex_t cpu_lock __cacheline_aligned;
int ncpu __read_mostly;
int ncpuonline __read_mostly;
@@ -104,7 +106,7 @@
kcpuset_set(kcpuset_running, 0);
ci = curcpu();
- ci->ci_smt_primary = ci;
+ cpu_topology_fake1(ci);
}
int
@@ -207,6 +209,27 @@
/*
* Fake up topology info if we have none, or if what we got was bogus.
+ * Used early in boot, and by cpu_topology_fake().
+ */
+static void
+cpu_topology_fake1(struct cpu_info *ci)
+{
+ enum cpu_rel rel;
+
+ for (rel = 0; rel < __arraycount(ci->ci_sibling); rel++) {
+ ci->ci_sibling[rel] = ci;
+ ci->ci_nsibling[rel] = 1;
+ }
+ if (!cpu_topology_present) {
+ ci->ci_package_id = cpu_index(ci);
+ }
+ ci->ci_smt_primary = ci;
+ ci->ci_schedstate.spc_flags |= SPCF_SMTPRIMARY;
+ cpu_topology_dump();
+}
+
+/*
+ * Fake up topology info if we have none, or if what we got was bogus.
* Don't override ci_package_id, etc, if cpu_topology_present is set.
* MD code also uses these.
*/
@@ -215,18 +238,9 @@
{
CPU_INFO_ITERATOR cii;
struct cpu_info *ci;
- enum cpu_rel rel;
for (CPU_INFO_FOREACH(cii, ci)) {
- for (rel = 0; rel < __arraycount(ci->ci_sibling); rel++) {
- ci->ci_sibling[rel] = ci;
- ci->ci_nsibling[rel] = 1;
- }
- if (!cpu_topology_present) {
- ci->ci_package_id = cpu_index(ci);
- }
- ci->ci_smt_primary = ci;
- ci->ci_schedstate.spc_flags |= SPCF_SMTPRIMARY;
+ cpu_topology_fake1(ci);
}
cpu_topology_dump();
}
Home |
Main Index |
Thread Index |
Old Index