From nobody Fri Nov 7 09:22:24 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547440759284654.1515843538191; Sun, 13 Jan 2019 20:39:19 -0800 (PST) Received: from localhost ([127.0.0.1]:56350 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1giu1b-0008HU-Is for importer@patchew.org; Sun, 13 Jan 2019 23:38:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40687) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gitzt-0007YU-MM for qemu-devel@nongnu.org; Sun, 13 Jan 2019 23:37:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gitzq-0002WI-FL for qemu-devel@nongnu.org; Sun, 13 Jan 2019 23:37:11 -0500 Received: from mga05.intel.com ([192.55.52.43]:15389) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gitzo-0002TQ-16 for qemu-devel@nongnu.org; Sun, 13 Jan 2019 23:37:09 -0500 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jan 2019 20:37:04 -0800 Received: from xulike-server.sh.intel.com ([10.239.48.60]) by fmsmga005.fm.intel.com with ESMTP; 13 Jan 2019 20:37:02 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,476,1539673200"; d="scan'208";a="311554079" From: Like Xu To: qemu-devel@nongnu.org Date: Mon, 14 Jan 2019 20:24:56 +0800 Message-Id: <1547468699-17633-3-git-send-email-like.xu@linux.intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1547468699-17633-1-git-send-email-like.xu@linux.intel.com> References: <1547468699-17633-1-git-send-email-like.xu@linux.intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.43 Subject: [Qemu-devel] [PATCH v1 2/5] vl.c: add -smp, dies=* command line support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: drjones@redhat.com, Peter Crosthwaite , Eduardo Habkost , "Michael S. Tsirkin" , like.xu@intel.com, Marcelo Tosatti , Paolo Bonzini , imammedo@redhat.com, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch updates the check rules on legeacy -smp parse from user command and it's designed to obey the same restrictions as socket/core/thread model. Signed-off-by: Like Xu --- hmp.c | 3 +++ hw/core/machine.c | 12 ++++++++++++ vl.c | 33 ++++++++++++++++++++------------- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/hmp.c b/hmp.c index 80aa5ab..05ac133 100644 --- a/hmp.c +++ b/hmp.c @@ -3013,6 +3013,9 @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict = *qdict) if (c->has_socket_id) { monitor_printf(mon, " socket-id: \"%" PRIu64 "\"\n", c->soc= ket_id); } + if (c->has_die_id) { + monitor_printf(mon, " die-id: \"%" PRIu64 "\"\n", c->die_id= ); + } if (c->has_core_id) { monitor_printf(mon, " core-id: \"%" PRIu64 "\"\n", c->core_= id); } diff --git a/hw/core/machine.c b/hw/core/machine.c index 95dc7c3..05bc545 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -601,6 +601,11 @@ void machine_set_cpu_numa_node(MachineState *machine, return; } =20 + if (props->has_die_id && !slot->props.has_die_id) { + error_setg(errp, "die-id is not supported"); + return; + } + if (props->has_socket_id && !slot->props.has_socket_id) { error_setg(errp, "socket-id is not supported"); return; @@ -615,6 +620,10 @@ void machine_set_cpu_numa_node(MachineState *machine, continue; } =20 + if (props->has_die_id && props->die_id !=3D slot->props.die_id) { + continue; + } + if (props->has_socket_id && props->socket_id !=3D slot->props.sock= et_id) { continue; } @@ -849,6 +858,9 @@ static char *cpu_slot_to_string(const CPUArchId *cpu) if (cpu->props.has_socket_id) { g_string_append_printf(s, "socket-id: %"PRId64, cpu->props.socket_= id); } + if (cpu->props.has_die_id) { + g_string_append_printf(s, "die-id: %"PRId64, cpu->props.die_id); + } if (cpu->props.has_core_id) { if (s->len) { g_string_append_printf(s, ", "); diff --git a/vl.c b/vl.c index 9b8ea3f..72be689 100644 --- a/vl.c +++ b/vl.c @@ -169,6 +169,7 @@ int win2k_install_hack =3D 0; int singlestep =3D 0; int smp_cpus; unsigned int max_cpus; +int smp_dies =3D 1; int smp_cores =3D 1; int smp_threads =3D 1; int acpi_enabled =3D 1; @@ -1208,6 +1209,9 @@ static QemuOptsList qemu_smp_opts =3D { .name =3D "sockets", .type =3D QEMU_OPT_NUMBER, }, { + .name =3D "dies", + .type =3D QEMU_OPT_NUMBER, + }, { .name =3D "cores", .type =3D QEMU_OPT_NUMBER, }, { @@ -1226,32 +1230,34 @@ static void smp_parse(QemuOpts *opts) if (opts) { unsigned cpus =3D qemu_opt_get_number(opts, "cpus", 0); unsigned sockets =3D qemu_opt_get_number(opts, "sockets", 0); + unsigned dies =3D qemu_opt_get_number(opts, "dies", 0); unsigned cores =3D qemu_opt_get_number(opts, "cores", 0); unsigned threads =3D qemu_opt_get_number(opts, "threads", 0); =20 /* compute missing values, prefer sockets over cores over threads = */ + dies =3D dies > 0 ? dies : 1; if (cpus =3D=3D 0 || sockets =3D=3D 0) { cores =3D cores > 0 ? cores : 1; threads =3D threads > 0 ? threads : 1; if (cpus =3D=3D 0) { sockets =3D sockets > 0 ? sockets : 1; - cpus =3D cores * threads * sockets; + cpus =3D cores * threads * dies * sockets; } else { max_cpus =3D qemu_opt_get_number(opts, "maxcpus", cpus); - sockets =3D max_cpus / (cores * threads); + sockets =3D max_cpus / (cores * threads * dies); } } else if (cores =3D=3D 0) { threads =3D threads > 0 ? threads : 1; - cores =3D cpus / (sockets * threads); + cores =3D cpus / (sockets * dies * threads); cores =3D cores > 0 ? cores : 1; } else if (threads =3D=3D 0) { - threads =3D cpus / (cores * sockets); + threads =3D cpus / (cores * dies * sockets); threads =3D threads > 0 ? threads : 1; - } else if (sockets * cores * threads < cpus) { + } else if (sockets * dies * cores * threads < cpus) { error_report("cpu topology: " - "sockets (%u) * cores (%u) * threads (%u) < " + "sockets (%u) * dies (%u) * cores (%u) * threads = (%u) < " "smp_cpus (%u)", - sockets, cores, threads, cpus); + sockets, dies, cores, threads, cpus); exit(1); } =20 @@ -1262,22 +1268,23 @@ static void smp_parse(QemuOpts *opts) exit(1); } =20 - if (sockets * cores * threads > max_cpus) { + if (sockets * dies * cores * threads > max_cpus) { error_report("cpu topology: " - "sockets (%u) * cores (%u) * threads (%u) > " + "sockets (%u) * dies (%u) * cores (%u) * threads = (%u) > " "maxcpus (%u)", - sockets, cores, threads, max_cpus); + sockets, dies, cores, threads, max_cpus); exit(1); } =20 - if (sockets * cores * threads !=3D max_cpus) { + if (sockets * dies * cores * threads !=3D max_cpus) { warn_report("Invalid CPU topology deprecated: " - "sockets (%u) * cores (%u) * threads (%u) " + "sockets (%u) * dies (%u) * cores (%u) * threads (= %u) " "!=3D maxcpus (%u)", - sockets, cores, threads, max_cpus); + sockets, dies, cores, threads, max_cpus); } =20 smp_cpus =3D cpus; + smp_dies =3D dies; smp_cores =3D cores; smp_threads =3D threads; } --=20 1.8.3.1