From: Anup Patel <anup.patel@wdc.com>
To: Eduardo Habkost <ehabkost@redhat.com>,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
Peter Maydell <peter.maydell@linaro.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Alistair Francis <Alistair.Francis@wdc.com>,
Sagar Karandikar <sagark@eecs.berkeley.edu>
Cc: Atish Patra <atish.patra@wdc.com>,
Anup Patel <anup.patel@wdc.com>,
qemu-riscv@nongnu.org, qemu-devel@nongnu.org,
Anup Patel <anup@brainfault.org>
Subject: [PATCH v2 1/5] hw: Add sockets_specified field in CpuTopology
Date: Wed, 27 May 2020 11:12:22 +0530 [thread overview]
Message-ID: <20200527054226.232103-2-anup.patel@wdc.com> (raw)
In-Reply-To: <20200527054226.232103-1-anup.patel@wdc.com>
When "sockets" sub-option of "-smp" option is not specified, the
smp_parse() function will assume one CPU per-socket and set the
number of sockets equal to number of CPUs.
This is counter-intuitive and we should allow machine emulation to
decide default number of sockets when "sockets" sub-option is not
specified. To achieve this, we add boolean flag sockets_specified
in struct CpuTopology which tells machine emulation whether the
"sockets" sub-option was specified in command-line.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
---
hw/core/machine.c | 2 ++
include/hw/boards.h | 2 ++
2 files changed, 4 insertions(+)
diff --git a/hw/core/machine.c b/hw/core/machine.c
index bb3a7b18b1..fd5ef5a4bb 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -706,6 +706,8 @@ static void smp_parse(MachineState *ms, QemuOpts *opts)
unsigned cores = qemu_opt_get_number(opts, "cores", 0);
unsigned threads = qemu_opt_get_number(opts, "threads", 0);
+ ms->smp.sockets_specified = (sockets == 0) ? false : true;
+
/* compute missing values, prefer sockets over cores over threads */
if (cpus == 0 || sockets == 0) {
cores = cores > 0 ? cores : 1;
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 18815d9be2..59b28ada65 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -244,6 +244,7 @@ typedef struct DeviceMemoryState {
* @cores: the number of cores in one package
* @threads: the number of threads in one core
* @sockets: the number of sockets on the machine
+ * @sockets_specified: the number of sockets were specified for the machine
* @max_cpus: the maximum number of logical processors on the machine
*/
typedef struct CpuTopology {
@@ -251,6 +252,7 @@ typedef struct CpuTopology {
unsigned int cores;
unsigned int threads;
unsigned int sockets;
+ bool sockets_specified;
unsigned int max_cpus;
} CpuTopology;
--
2.25.1
next prev parent reply other threads:[~2020-05-27 5:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-27 5:42 [PATCH v2 0/5] RISC-V multi-socket support Anup Patel
2020-05-27 5:42 ` Anup Patel [this message]
2020-05-27 8:45 ` [PATCH v2 1/5] hw: Add sockets_specified field in CpuTopology Daniel P. Berrangé
2020-05-27 9:48 ` Anup Patel
2020-05-27 9:51 ` Daniel P. Berrangé
2020-05-27 10:01 ` Anup Patel
2020-05-27 10:42 ` Daniel P. Berrangé
2020-05-27 10:55 ` Anup Patel
2020-05-27 5:42 ` [PATCH v2 2/5] hw/riscv: Allow creating multiple instances of CLINT Anup Patel
2020-05-27 5:42 ` [PATCH v2 3/5] hw/riscv: spike: Allow creating multiple sockets Anup Patel
2020-05-27 5:42 ` [PATCH v2 4/5] hw/riscv: Allow creating multiple instances of PLIC Anup Patel
2020-05-27 5:42 ` [PATCH v2 5/5] hw/riscv: virt: Allow creating multiple sockets Anup Patel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200527054226.232103-2-anup.patel@wdc.com \
--to=anup.patel@wdc.com \
--cc=Alistair.Francis@wdc.com \
--cc=anup@brainfault.org \
--cc=atish.patra@wdc.com \
--cc=ehabkost@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=palmer@dabbelt.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=sagark@eecs.berkeley.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).