qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH 3/6] pc/machine: Perform zero-check for the value of -smp die


From: Yanan Wang
Subject: [RFC PATCH 3/6] pc/machine: Perform zero-check for the value of -smp dies
Date: Fri, 2 Jul 2021 18:07:36 +0800

It's possible that dies parameter is explicitly specified as "dies=0"
in the cmdline, if so we will wrongly calculate the other ommited
parameters such as "sockets = maxcpus / (dies * cores * threads);"
with a zeroed dies value.

So perform zero-check (default the value to 1 if zeroed) for -smp dies
before using it to calculate other parameters.

Fixes: 1b45842203540 (vl.c: Add -smp, dies=* command line support and update 
doc)
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
---
 hw/i386/pc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index a44511c937..93d1f12a49 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -714,12 +714,14 @@ static void pc_smp_parse(MachineState *ms, 
SMPConfiguration *config, Error **err
 {
     unsigned cpus    = config->has_cpus ? config->cpus : 0;
     unsigned sockets = config->has_sockets ? config->sockets : 0;
-    unsigned dies    = config->has_dies ? config->dies : 1;
+    unsigned dies    = config->has_dies ? config->dies : 0;
     unsigned cores   = config->has_cores ? config->cores : 0;
     unsigned threads = config->has_threads ? config->threads : 0;
     unsigned maxcpus = config->has_maxcpus ? config->maxcpus : 0;
 
     /* compute missing values, prefer sockets over cores over threads */
+    dies = dies > 0 ? dies : 1;
+
     if (cpus == 0 || sockets == 0) {
         cores = cores > 0 ? cores : 1;
         threads = threads > 0 ? threads : 1;
-- 
2.19.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]