Rename ci_node_id to ci_package_id, as some claim that the former might be confused with NUMA node.diff -r1.5 -r1.6 src/sys/arch/x86/x86/cpu_topology.c
(rmind)
--- src/sys/arch/x86/x86/cpu_topology.c 2010/05/09 20:32:41 1.5
+++ src/sys/arch/x86/x86/cpu_topology.c 2010/05/29 05:53:57 1.6
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: cpu_topology.c,v 1.5 2010/05/09 20:32:41 rmind Exp $ */ | 1 | /* $NetBSD: cpu_topology.c,v 1.6 2010/05/29 05:53:57 rmind Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2009 Mindaugas Rasiukevicius <rmind at NetBSD org>, | 4 | * Copyright (c) 2009 Mindaugas Rasiukevicius <rmind at NetBSD org>, | |
5 | * Copyright (c) 2008 YAMAMOTO Takashi, | 5 | * Copyright (c) 2008 YAMAMOTO Takashi, | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
@@ -26,51 +26,51 @@ | @@ -26,51 +26,51 @@ | |||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
27 | * SUCH DAMAGE. | 27 | * SUCH DAMAGE. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | /* | 30 | /* | |
31 | * x86 CPU topology detection. | 31 | * x86 CPU topology detection. | |
32 | * | 32 | * | |
33 | * References: | 33 | * References: | |
34 | * - 53668.pdf (7.10.2), 276613.pdf | 34 | * - 53668.pdf (7.10.2), 276613.pdf | |
35 | * - 31116.pdf, 41256.pdf, 25481.pdf | 35 | * - 31116.pdf, 41256.pdf, 25481.pdf | |
36 | */ | 36 | */ | |
37 | 37 | |||
38 | #include <sys/cdefs.h> | 38 | #include <sys/cdefs.h> | |
39 | __KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.5 2010/05/09 20:32:41 rmind Exp $"); | 39 | __KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.6 2010/05/29 05:53:57 rmind Exp $"); | |
40 | 40 | |||
41 | #include <sys/param.h> | 41 | #include <sys/param.h> | |
42 | #include <sys/bitops.h> | 42 | #include <sys/bitops.h> | |
43 | 43 | |||
44 | #include <machine/specialreg.h> | 44 | #include <machine/specialreg.h> | |
45 | #include <machine/cpu.h> | 45 | #include <machine/cpu.h> | |
46 | 46 | |||
47 | #include <x86/cpufunc.h> | 47 | #include <x86/cpufunc.h> | |
48 | #include <x86/cputypes.h> | 48 | #include <x86/cputypes.h> | |
49 | #include <x86/cpuvar.h> | 49 | #include <x86/cpuvar.h> | |
50 | 50 | |||
51 | void | 51 | void | |
52 | x86_cpu_topology(struct cpu_info *ci) | 52 | x86_cpu_topology(struct cpu_info *ci) | |
53 | { | 53 | { | |
54 | u_int lp_max; /* Logical processors per package (node) */ | 54 | u_int lp_max; /* Logical processors per package (node) */ | |
55 | u_int core_max; /* Core per package */ | 55 | u_int core_max; /* Core per package */ | |
56 | int n, cpu_family, apic_id, smt_bits, core_bits = 0; | 56 | int n, cpu_family, apic_id, smt_bits, core_bits = 0; | |
57 | uint32_t descs[4], lextmode; | 57 | uint32_t descs[4], lextmode; | |
58 | 58 | |||
59 | apic_id = ci->ci_initapicid; | 59 | apic_id = ci->ci_initapicid; | |
60 | cpu_family = CPUID2FAMILY(ci->ci_signature); | 60 | cpu_family = CPUID2FAMILY(ci->ci_signature); | |
61 | 61 | |||
62 | /* Initial values. */ | 62 | /* Initial values. */ | |
63 | ci->ci_node_id = apic_id; | 63 | ci->ci_package_id = apic_id; | |
64 | ci->ci_core_id = 0; | 64 | ci->ci_core_id = 0; | |
65 | ci->ci_smt_id = 0; | 65 | ci->ci_smt_id = 0; | |
66 | 66 | |||
67 | switch (cpu_vendor) { | 67 | switch (cpu_vendor) { | |
68 | case CPUVENDOR_INTEL: | 68 | case CPUVENDOR_INTEL: | |
69 | if (cpu_family < 6) | 69 | if (cpu_family < 6) | |
70 | return; | 70 | return; | |
71 | break; | 71 | break; | |
72 | case CPUVENDOR_AMD: | 72 | case CPUVENDOR_AMD: | |
73 | if (cpu_family < 0xf) | 73 | if (cpu_family < 0xf) | |
74 | return; | 74 | return; | |
75 | break; | 75 | break; | |
76 | default: | 76 | default: | |
@@ -151,24 +151,24 @@ x86_cpu_topology(struct cpu_info *ci) | @@ -151,24 +151,24 @@ x86_cpu_topology(struct cpu_info *ci) | |||
151 | if ((reg & NB_CFG_INITAPICCPUIDLO) == 0) { | 151 | if ((reg & NB_CFG_INITAPICCPUIDLO) == 0) { | |
152 | /* | 152 | /* | |
153 | * 0xf: { CoreId, NodeId[2:0] } | 153 | * 0xf: { CoreId, NodeId[2:0] } | |
154 | * 0x10: { CoreId[1:0], 000b, NodeId[2:0] } | 154 | * 0x10: { CoreId[1:0], 000b, NodeId[2:0] } | |
155 | */ | 155 | */ | |
156 | const u_int node_id = apic_id & __BITS(0, 2); | 156 | const u_int node_id = apic_id & __BITS(0, 2); | |
157 | apic_id = (cpu_family == 0xf) ? | 157 | apic_id = (cpu_family == 0xf) ? | |
158 | (apic_id >> core_bits) | (node_id << core_bits) : | 158 | (apic_id >> core_bits) | (node_id << core_bits) : | |
159 | (apic_id >> 5) | (node_id << 2); | 159 | (apic_id >> 5) | (node_id << 2); | |
160 | } | 160 | } | |
161 | } | 161 | } | |
162 | 162 | |||
163 | if (smt_bits + core_bits) { | 163 | if (smt_bits + core_bits) { | |
164 | ci->ci_node_id = apic_id >> (smt_bits + core_bits); | 164 | ci->ci_package_id = apic_id >> (smt_bits + core_bits); | |
165 | } | 165 | } | |
166 | if (core_bits) { | 166 | if (core_bits) { | |
167 | u_int core_mask = __BITS(smt_bits, smt_bits + core_bits - 1); | 167 | u_int core_mask = __BITS(smt_bits, smt_bits + core_bits - 1); | |
168 | ci->ci_core_id = __SHIFTOUT(apic_id, core_mask); | 168 | ci->ci_core_id = __SHIFTOUT(apic_id, core_mask); | |
169 | } | 169 | } | |
170 | if (smt_bits) { | 170 | if (smt_bits) { | |
171 | u_int smt_mask = __BITS(0, smt_bits - 1); | 171 | u_int smt_mask = __BITS(0, smt_bits - 1); | |
172 | ci->ci_smt_id = __SHIFTOUT(apic_id, smt_mask); | 172 | ci->ci_smt_id = __SHIFTOUT(apic_id, smt_mask); | |
173 | } | 173 | } | |
174 | } | 174 | } |
--- src/sys/sys/cpu_data.h 2010/05/09 20:18:40 1.30
+++ src/sys/sys/cpu_data.h 2010/05/29 05:53:57 1.31
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: cpu_data.h,v 1.30 2010/05/09 20:18:40 rmind Exp $ */ | 1 | /* $NetBSD: cpu_data.h,v 1.31 2010/05/29 05:53:57 rmind Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -61,27 +61,27 @@ struct cpu_data { | @@ -61,27 +61,27 @@ struct cpu_data { | |||
61 | * The first section is likely to be touched by other CPUs - | 61 | * The first section is likely to be touched by other CPUs - | |
62 | * it is cache hot. | 62 | * it is cache hot. | |
63 | */ | 63 | */ | |
64 | lwp_t *cpu_biglock_wanted; /* LWP spinning on biglock */ | 64 | lwp_t *cpu_biglock_wanted; /* LWP spinning on biglock */ | |
65 | void *cpu_callout; /* per-CPU callout state */ | 65 | void *cpu_callout; /* per-CPU callout state */ | |
66 | void *cpu_unused1; /* unused */ | 66 | void *cpu_unused1; /* unused */ | |
67 | u_int cpu_unused2; /* unused */ | 67 | u_int cpu_unused2; /* unused */ | |
68 | struct schedstate_percpu cpu_schedstate; /* scheduler state */ | 68 | struct schedstate_percpu cpu_schedstate; /* scheduler state */ | |
69 | kcondvar_t cpu_xcall; /* cross-call support */ | 69 | kcondvar_t cpu_xcall; /* cross-call support */ | |
70 | int cpu_xcall_pending; /* cross-call support */ | 70 | int cpu_xcall_pending; /* cross-call support */ | |
71 | lwp_t *cpu_onproc; /* bottom level LWP */ | 71 | lwp_t *cpu_onproc; /* bottom level LWP */ | |
72 | CIRCLEQ_ENTRY(cpu_info) cpu_qchain; /* circleq of all CPUs */ | 72 | CIRCLEQ_ENTRY(cpu_info) cpu_qchain; /* circleq of all CPUs */ | |
73 | 73 | |||
74 | cpuid_t cpu_node_id; | 74 | cpuid_t cpu_package_id; | |
75 | cpuid_t cpu_core_id; | 75 | cpuid_t cpu_core_id; | |
76 | cpuid_t cpu_smt_id; | 76 | cpuid_t cpu_smt_id; | |
77 | 77 | |||
78 | /* | 78 | /* | |
79 | * This section is mostly CPU-private. | 79 | * This section is mostly CPU-private. | |
80 | */ | 80 | */ | |
81 | lwp_t *cpu_idlelwp; /* idle lwp */ | 81 | lwp_t *cpu_idlelwp; /* idle lwp */ | |
82 | void *cpu_lockstat; /* lockstat private tables */ | 82 | void *cpu_lockstat; /* lockstat private tables */ | |
83 | u_int cpu_index; /* CPU index */ | 83 | u_int cpu_index; /* CPU index */ | |
84 | u_int cpu_biglock_count; /* # recursive holds */ | 84 | u_int cpu_biglock_count; /* # recursive holds */ | |
85 | u_int cpu_spin_locks; /* # of spinlockmgr locks */ | 85 | u_int cpu_spin_locks; /* # of spinlockmgr locks */ | |
86 | u_int cpu_simple_locks; /* # of simple locks held */ | 86 | u_int cpu_simple_locks; /* # of simple locks held */ | |
87 | u_int cpu_spin_locks2; /* # of spin locks held XXX */ | 87 | u_int cpu_spin_locks2; /* # of spin locks held XXX */ | |
@@ -104,20 +104,20 @@ struct cpu_data { | @@ -104,20 +104,20 @@ struct cpu_data { | |||
104 | }; | 104 | }; | |
105 | 105 | |||
106 | /* compat definitions */ | 106 | /* compat definitions */ | |
107 | #define ci_schedstate ci_data.cpu_schedstate | 107 | #define ci_schedstate ci_data.cpu_schedstate | |
108 | #define ci_index ci_data.cpu_index | 108 | #define ci_index ci_data.cpu_index | |
109 | #define ci_biglock_count ci_data.cpu_biglock_count | 109 | #define ci_biglock_count ci_data.cpu_biglock_count | |
110 | #define ci_biglock_wanted ci_data.cpu_biglock_wanted | 110 | #define ci_biglock_wanted ci_data.cpu_biglock_wanted | |
111 | #define ci_spin_locks ci_data.cpu_spin_locks | 111 | #define ci_spin_locks ci_data.cpu_spin_locks | |
112 | #define ci_simple_locks ci_data.cpu_simple_locks | 112 | #define ci_simple_locks ci_data.cpu_simple_locks | |
113 | #define ci_lockstat ci_data.cpu_lockstat | 113 | #define ci_lockstat ci_data.cpu_lockstat | |
114 | #define ci_spin_locks2 ci_data.cpu_spin_locks2 | 114 | #define ci_spin_locks2 ci_data.cpu_spin_locks2 | |
115 | #define ci_lkdebug_recurse ci_data.cpu_lkdebug_recurse | 115 | #define ci_lkdebug_recurse ci_data.cpu_lkdebug_recurse | |
116 | 116 | |||
117 | #define ci_node_id ci_data.cpu_node_id | 117 | #define ci_package_id ci_data.cpu_package_id | |
118 | #define ci_core_id ci_data.cpu_core_id | 118 | #define ci_core_id ci_data.cpu_core_id | |
119 | #define ci_smt_id ci_data.cpu_smt_id | 119 | #define ci_smt_id ci_data.cpu_smt_id | |
120 | 120 | |||
121 | int mi_cpu_attach(struct cpu_info *ci); | 121 | int mi_cpu_attach(struct cpu_info *ci); | |
122 | 122 | |||
123 | #endif /* _SYS_CPU_DATA_H_ */ | 123 | #endif /* _SYS_CPU_DATA_H_ */ |