Lines Matching +full:0 +full:ms
31 static char *cpu_hierarchy_to_string(MachineState *ms) in cpu_hierarchy_to_string() argument
33 MachineClass *mc = MACHINE_GET_CLASS(ms); in cpu_hierarchy_to_string()
37 g_string_append_printf(s, "drawers (%u) * ", ms->smp.drawers); in cpu_hierarchy_to_string()
41 g_string_append_printf(s, "books (%u) * ", ms->smp.books); in cpu_hierarchy_to_string()
44 g_string_append_printf(s, "sockets (%u)", ms->smp.sockets); in cpu_hierarchy_to_string()
47 g_string_append_printf(s, " * dies (%u)", ms->smp.dies); in cpu_hierarchy_to_string()
51 g_string_append_printf(s, " * clusters (%u)", ms->smp.clusters); in cpu_hierarchy_to_string()
55 g_string_append_printf(s, " * modules (%u)", ms->smp.modules); in cpu_hierarchy_to_string()
58 g_string_append_printf(s, " * cores (%u)", ms->smp.cores); in cpu_hierarchy_to_string()
59 g_string_append_printf(s, " * threads (%u)", ms->smp.threads); in cpu_hierarchy_to_string()
85 void machine_parse_smp_config(MachineState *ms, in machine_parse_smp_config() argument
88 MachineClass *mc = MACHINE_GET_CLASS(ms); in machine_parse_smp_config()
89 unsigned cpus = config->has_cpus ? config->cpus : 0; in machine_parse_smp_config()
90 unsigned drawers = config->has_drawers ? config->drawers : 0; in machine_parse_smp_config()
91 unsigned books = config->has_books ? config->books : 0; in machine_parse_smp_config()
92 unsigned sockets = config->has_sockets ? config->sockets : 0; in machine_parse_smp_config()
93 unsigned dies = config->has_dies ? config->dies : 0; in machine_parse_smp_config()
94 unsigned clusters = config->has_clusters ? config->clusters : 0; in machine_parse_smp_config()
95 unsigned modules = config->has_modules ? config->modules : 0; in machine_parse_smp_config()
96 unsigned cores = config->has_cores ? config->cores : 0; in machine_parse_smp_config()
97 unsigned threads = config->has_threads ? config->threads : 0; in machine_parse_smp_config()
98 unsigned maxcpus = config->has_maxcpus ? config->maxcpus : 0; in machine_parse_smp_config()
103 * explicit configuration like "cpus=0" is not allowed. in machine_parse_smp_config()
105 if ((config->has_cpus && config->cpus == 0) || in machine_parse_smp_config()
106 (config->has_drawers && config->drawers == 0) || in machine_parse_smp_config()
107 (config->has_books && config->books == 0) || in machine_parse_smp_config()
108 (config->has_sockets && config->sockets == 0) || in machine_parse_smp_config()
109 (config->has_dies && config->dies == 0) || in machine_parse_smp_config()
110 (config->has_clusters && config->clusters == 0) || in machine_parse_smp_config()
111 (config->has_modules && config->modules == 0) || in machine_parse_smp_config()
112 (config->has_cores && config->cores == 0) || in machine_parse_smp_config()
113 (config->has_threads && config->threads == 0) || in machine_parse_smp_config()
114 (config->has_maxcpus && config->maxcpus == 0)) { in machine_parse_smp_config()
130 modules = modules > 0 ? modules : 1; in machine_parse_smp_config()
138 clusters = clusters > 0 ? clusters : 1; in machine_parse_smp_config()
146 dies = dies > 0 ? dies : 1; in machine_parse_smp_config()
154 books = books > 0 ? books : 1; in machine_parse_smp_config()
162 drawers = drawers > 0 ? drawers : 1; in machine_parse_smp_config()
165 if (cpus == 0 && maxcpus == 0) { in machine_parse_smp_config()
166 sockets = sockets > 0 ? sockets : 1; in machine_parse_smp_config()
167 cores = cores > 0 ? cores : 1; in machine_parse_smp_config()
168 threads = threads > 0 ? threads : 1; in machine_parse_smp_config()
170 maxcpus = maxcpus > 0 ? maxcpus : cpus; in machine_parse_smp_config()
174 if (sockets == 0) { in machine_parse_smp_config()
175 cores = cores > 0 ? cores : 1; in machine_parse_smp_config()
176 threads = threads > 0 ? threads : 1; in machine_parse_smp_config()
180 } else if (cores == 0) { in machine_parse_smp_config()
181 threads = threads > 0 ? threads : 1; in machine_parse_smp_config()
188 if (cores == 0) { in machine_parse_smp_config()
189 sockets = sockets > 0 ? sockets : 1; in machine_parse_smp_config()
190 threads = threads > 0 ? threads : 1; in machine_parse_smp_config()
194 } else if (sockets == 0) { in machine_parse_smp_config()
195 threads = threads > 0 ? threads : 1; in machine_parse_smp_config()
203 if (threads == 0) { in machine_parse_smp_config()
212 maxcpus = maxcpus > 0 ? maxcpus : total_cpus; in machine_parse_smp_config()
213 cpus = cpus > 0 ? cpus : maxcpus; in machine_parse_smp_config()
215 ms->smp.cpus = cpus; in machine_parse_smp_config()
216 ms->smp.drawers = drawers; in machine_parse_smp_config()
217 ms->smp.books = books; in machine_parse_smp_config()
218 ms->smp.sockets = sockets; in machine_parse_smp_config()
219 ms->smp.dies = dies; in machine_parse_smp_config()
220 ms->smp.clusters = clusters; in machine_parse_smp_config()
221 ms->smp.modules = modules; in machine_parse_smp_config()
222 ms->smp.cores = cores; in machine_parse_smp_config()
223 ms->smp.threads = threads; in machine_parse_smp_config()
224 ms->smp.max_cpus = maxcpus; in machine_parse_smp_config()
230 g_autofree char *topo_msg = cpu_hierarchy_to_string(ms); in machine_parse_smp_config()
239 g_autofree char *topo_msg = cpu_hierarchy_to_string(ms); in machine_parse_smp_config()
247 if (ms->smp.cpus < mc->min_cpus) { in machine_parse_smp_config()
250 ms->smp.cpus, in machine_parse_smp_config()
255 if (ms->smp.max_cpus > mc->max_cpus) { in machine_parse_smp_config()
258 ms->smp.max_cpus, in machine_parse_smp_config()
264 static bool machine_check_topo_support(MachineState *ms, in machine_check_topo_support() argument
268 MachineClass *mc = MACHINE_GET_CLASS(ms); in machine_check_topo_support()
285 bool machine_parse_smp_cache(MachineState *ms, in machine_parse_smp_cache() argument
289 MachineClass *mc = MACHINE_GET_CLASS(ms); in machine_parse_smp_cache()
304 machine_set_cache_topo_level(ms, node->value->cache, in machine_parse_smp_cache()
309 for (int i = 0; i < CACHE_LEVEL_AND_TYPE__MAX; i++) { in machine_parse_smp_cache()
310 const SmpCacheProperties *props = &ms->smp_cache.props[i]; in machine_parse_smp_cache()
324 if (!machine_check_topo_support(ms, props->topology, errp)) { in machine_parse_smp_cache()
331 unsigned int machine_topo_get_cores_per_socket(const MachineState *ms) in machine_topo_get_cores_per_socket() argument
333 return ms->smp.cores * ms->smp.modules * ms->smp.clusters * ms->smp.dies; in machine_topo_get_cores_per_socket()
336 unsigned int machine_topo_get_threads_per_socket(const MachineState *ms) in machine_topo_get_threads_per_socket() argument
338 return ms->smp.threads * machine_topo_get_cores_per_socket(ms); in machine_topo_get_threads_per_socket()
341 CpuTopologyLevel machine_get_cache_topo_level(const MachineState *ms, in machine_get_cache_topo_level() argument
344 return ms->smp_cache.props[cache].topology; in machine_get_cache_topo_level()
347 void machine_set_cache_topo_level(MachineState *ms, CacheLevelAndType cache, in machine_set_cache_topo_level() argument
350 ms->smp_cache.props[cache].topology = level; in machine_set_cache_topo_level()
378 bool machine_check_smp_cache(const MachineState *ms, Error **errp) in machine_check_smp_cache() argument
380 if (smp_cache_topo_cmp(&ms->smp_cache, CACHE_LEVEL_AND_TYPE_L1D, in machine_check_smp_cache()
382 smp_cache_topo_cmp(&ms->smp_cache, CACHE_LEVEL_AND_TYPE_L1I, in machine_check_smp_cache()
390 if (smp_cache_topo_cmp(&ms->smp_cache, CACHE_LEVEL_AND_TYPE_L2, in machine_check_smp_cache()