Thu Jan 2 01:31:17 2020 UTC ()
mi_cpu_init: set ci_smt_primary early.


(ad)
diff -r1.3 -r1.4 src/sys/kern/subr_cpu.c

cvs diff -r1.3 -r1.4 src/sys/kern/subr_cpu.c (expand / switch to unified diff)

--- src/sys/kern/subr_cpu.c 2019/12/21 12:53:53 1.3
+++ src/sys/kern/subr_cpu.c 2020/01/02 01:31:17 1.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: subr_cpu.c,v 1.3 2019/12/21 12:53:53 ad Exp $ */ 1/* $NetBSD: subr_cpu.c,v 1.4 2020/01/02 01:31:17 ad Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2007, 2008, 2009, 2010, 2012, 2019 The NetBSD Foundation, Inc. 4 * Copyright (c) 2007, 2008, 2009, 2010, 2012, 2019 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Andrew Doran. 8 * by Andrew Doran.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -50,27 +50,27 @@ @@ -50,27 +50,27 @@
50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55 * SUCH DAMAGE. 55 * SUCH DAMAGE.
56 */ 56 */
57 57
58/* 58/*
59 * CPU related routines shared with rump. 59 * CPU related routines shared with rump.
60 */ 60 */
61 61
62#include <sys/cdefs.h> 62#include <sys/cdefs.h>
63__KERNEL_RCSID(0, "$NetBSD: subr_cpu.c,v 1.3 2019/12/21 12:53:53 ad Exp $"); 63__KERNEL_RCSID(0, "$NetBSD: subr_cpu.c,v 1.4 2020/01/02 01:31:17 ad Exp $");
64 64
65#include <sys/param.h> 65#include <sys/param.h>
66#include <sys/systm.h> 66#include <sys/systm.h>
67#include <sys/sched.h> 67#include <sys/sched.h>
68#include <sys/conf.h> 68#include <sys/conf.h>
69#include <sys/cpu.h> 69#include <sys/cpu.h>
70#include <sys/proc.h> 70#include <sys/proc.h>
71#include <sys/kernel.h> 71#include <sys/kernel.h>
72#include <sys/kmem.h> 72#include <sys/kmem.h>
73 73
74kmutex_t cpu_lock __cacheline_aligned; 74kmutex_t cpu_lock __cacheline_aligned;
75int ncpu __read_mostly; 75int ncpu __read_mostly;
76int ncpuonline __read_mostly; 76int ncpuonline __read_mostly;
@@ -85,32 +85,36 @@ struct cpu_info **cpu_infos __read_most @@ -85,32 +85,36 @@ struct cpu_info **cpu_infos __read_most
85kcpuset_t * kcpuset_attached __read_mostly = NULL; 85kcpuset_t * kcpuset_attached __read_mostly = NULL;
86kcpuset_t * kcpuset_running __read_mostly = NULL; 86kcpuset_t * kcpuset_running __read_mostly = NULL;
87 87
88static char cpu_model[128]; 88static char cpu_model[128];
89 89
90/* 90/*
91 * mi_cpu_init: early initialisation of MI CPU related structures. 91 * mi_cpu_init: early initialisation of MI CPU related structures.
92 * 92 *
93 * Note: may not block and memory allocator is not yet available. 93 * Note: may not block and memory allocator is not yet available.
94 */ 94 */
95void 95void
96mi_cpu_init(void) 96mi_cpu_init(void)
97{ 97{
 98 struct cpu_info *ci;
98 99
99 mutex_init(&cpu_lock, MUTEX_DEFAULT, IPL_NONE); 100 mutex_init(&cpu_lock, MUTEX_DEFAULT, IPL_NONE);
100 101
101 kcpuset_create(&kcpuset_attached, true); 102 kcpuset_create(&kcpuset_attached, true);
102 kcpuset_create(&kcpuset_running, true); 103 kcpuset_create(&kcpuset_running, true);
103 kcpuset_set(kcpuset_running, 0); 104 kcpuset_set(kcpuset_running, 0);
 105
 106 ci = curcpu();
 107 ci->ci_smt_primary = ci;
104} 108}
105 109
106int 110int
107cpu_setmodel(const char *fmt, ...) 111cpu_setmodel(const char *fmt, ...)
108{ 112{
109 int len; 113 int len;
110 va_list ap; 114 va_list ap;
111 115
112 va_start(ap, fmt); 116 va_start(ap, fmt);
113 len = vsnprintf(cpu_model, sizeof(cpu_model), fmt, ap); 117 len = vsnprintf(cpu_model, sizeof(cpu_model), fmt, ap);
114 va_end(ap); 118 va_end(ap);
115 return len; 119 return len;
116} 120}