From nobody Tue Oct 7 20:22:08 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561688248; cv=none; d=zoho.com; s=zohoarc; b=mE1lbvK0tOmxM0qTWo/dTWs0FjYJ4kyGyEPZ+1jt1s4qZhG0cXKu22XLWkCQMjH4/mnEoEbGnrz3zugvlHuwB3dwQWH4xfb5EhnKWGZyTRAZfgE8VGppciP8g7jhlnNOyahtM51U2OVRUUpT8rwhM/PAb4FNSg9NYOIdH8gD5Us= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561688248; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=4KPGrp5Cyn6jLAJLGMRAUMzmt1ewtnbMkd5V5ga3EHI=; b=ojlM2ZYpEzhQyzgH1G9XsPZiwfXdkjqNwPypYAW7Yt919ujPtzzsiiWdtn9OupdSi8ziRThi5pn7DebOK4T8w9EV6+jC9So7BKnCQKsGZtb44Xtohjo2QGHXagfqEZkwwOTAgy9IttjX/waH1LHgyRooGohJVmj3StJeJkyhXYM= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561688248234793.144031597399; Thu, 27 Jun 2019 19:17:28 -0700 (PDT) Received: from localhost ([::1]:55732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hggS5-0005mn-Kx for importer@patchew.org; Thu, 27 Jun 2019 22:17:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49933) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgg89-0000fl-I2 for qemu-devel@nongnu.org; Thu, 27 Jun 2019 21:56:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgg87-0008W9-OP for qemu-devel@nongnu.org; Thu, 27 Jun 2019 21:56:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46298) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgg85-0008Q0-QI for qemu-devel@nongnu.org; Thu, 27 Jun 2019 21:56:47 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 13BEFC057F4F; Fri, 28 Jun 2019 01:56:45 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 954A119C70; Fri, 28 Jun 2019 01:56:44 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Thu, 27 Jun 2019 22:55:50 -0300 Message-Id: <20190628015606.32107-14-ehabkost@redhat.com> In-Reply-To: <20190628015606.32107-1-ehabkost@redhat.com> References: <20190628015606.32107-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 28 Jun 2019 01:56:45 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 13/29] i386/cpu: Consolidate die-id validity in smp context X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Like Xu , 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" From: Like Xu The field die_id (default as 0) and has_die_id are introduced to X86CPU. Following the legacy smp check rules, the die_id validity is added to the same contexts as leagcy smp variables such as hmp_hotpluggable_cpus(), machine_set_cpu_numa_node(), cpu_slot_to_string() and pc_cpu_pre_plug(). Acked-by: Dr. David Alan Gilbert Signed-off-by: Like Xu Message-Id: <20190612084104.34984-4-like.xu@linux.intel.com> Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- qapi/misc.json | 6 ++++-- include/hw/i386/topology.h | 2 ++ target/i386/cpu.h | 1 + hw/core/machine.c | 12 ++++++++++++ hw/i386/pc.c | 14 ++++++++++++++ monitor/hmp-cmds.c | 3 +++ target/i386/cpu.c | 2 ++ 7 files changed, 38 insertions(+), 2 deletions(-) diff --git a/qapi/misc.json b/qapi/misc.json index dc4cf9da20..577f7166f4 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -2920,10 +2920,11 @@ # # @node-id: NUMA node ID the CPU belongs to # @socket-id: socket number within node/board the CPU belongs to -# @core-id: core number within socket the CPU belongs to +# @die-id: die number within node/board the CPU belongs to (Since 4.1) +# @core-id: core number within die the CPU belongs to # @thread-id: thread number within core the CPU belongs to # -# Note: currently there are 4 properties that could be present +# Note: currently there are 5 properties that could be present # but management should be prepared to pass through other # properties with device_add command to allow for future # interface extension. This also requires the filed names to be kept in @@ -2934,6 +2935,7 @@ { 'struct': 'CpuInstanceProperties', 'data': { '*node-id': 'int', '*socket-id': 'int', + '*die-id': 'int', '*core-id': 'int', '*thread-id': 'int' } diff --git a/include/hw/i386/topology.h b/include/hw/i386/topology.h index 1ebaee0f76..c9fb41588e 100644 --- a/include/hw/i386/topology.h +++ b/include/hw/i386/topology.h @@ -47,6 +47,7 @@ typedef uint32_t apic_id_t; =20 typedef struct X86CPUTopoInfo { unsigned pkg_id; + unsigned die_id; unsigned core_id; unsigned smt_id; } X86CPUTopoInfo; @@ -130,6 +131,7 @@ static inline void x86_topo_ids_from_apicid(apic_id_t a= picid, topo->core_id =3D (apicid >> apicid_core_offset(nr_cores, nr_threads))= & ~(0xFFFFFFFFUL << apicid_core_width(nr_cores, nr_thread= s)); topo->pkg_id =3D apicid >> apicid_pkg_offset(nr_cores, nr_threads); + topo->die_id =3D 0; } =20 /* Make APIC ID for the CPU 'cpu_index' diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 14c19e61b1..4d2ae2384e 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1500,6 +1500,7 @@ struct X86CPU { =20 int32_t node_id; /* NUMA node this CPU belongs to */ int32_t socket_id; + int32_t die_id; int32_t core_id; int32_t thread_id; =20 diff --git a/hw/core/machine.c b/hw/core/machine.c index ea5a01aa49..7a44adab39 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -682,6 +682,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; + } + /* skip slots with explicit mismatch */ if (props->has_thread_id && props->thread_id !=3D slot->props.thre= ad_id) { continue; @@ -691,6 +696,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; } @@ -948,6 +957,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/hw/i386/pc.c b/hw/i386/pc.c index 211015324a..98a314dcf0 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -2327,6 +2327,10 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_= dev, error_setg(errp, "Invalid CPU socket-id: %u must be in range 0= :%u", cpu->socket_id, max_socket); return; + } else if (cpu->die_id > pcms->smp_dies - 1) { + error_setg(errp, "Invalid CPU die-id: %u must be in range 0:%u= ", + cpu->die_id, max_socket); + return; } if (cpu->core_id < 0) { error_setg(errp, "CPU core-id is not set"); @@ -2346,6 +2350,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, } =20 topo.pkg_id =3D cpu->socket_id; + topo.die_id =3D cpu->die_id; topo.core_id =3D cpu->core_id; topo.smt_id =3D cpu->thread_id; cpu->apic_id =3D apicid_from_topo_ids(smp_cores, smp_threads, &top= o); @@ -2383,6 +2388,13 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_= dev, } cpu->socket_id =3D topo.pkg_id; =20 + if (cpu->die_id !=3D -1 && cpu->die_id !=3D topo.die_id) { + error_setg(errp, "property die-id: %u doesn't match set apic-id:" + " 0x%x (die-id: %u)", cpu->die_id, cpu->apic_id, topo.die_id); + return; + } + cpu->die_id =3D topo.die_id; + if (cpu->core_id !=3D -1 && cpu->core_id !=3D topo.core_id) { error_setg(errp, "property core-id: %u doesn't match set apic-id:" " 0x%x (core-id: %u)", cpu->core_id, cpu->apic_id, topo.core_i= d); @@ -2700,6 +2712,8 @@ static const CPUArchIdList *pc_possible_cpu_arch_ids(= MachineState *ms) ms->smp.cores, ms->smp.threads, &topo); ms->possible_cpus->cpus[i].props.has_socket_id =3D true; ms->possible_cpus->cpus[i].props.socket_id =3D topo.pkg_id; + ms->possible_cpus->cpus[i].props.has_die_id =3D true; + ms->possible_cpus->cpus[i].props.die_id =3D topo.die_id; ms->possible_cpus->cpus[i].props.has_core_id =3D true; ms->possible_cpus->cpus[i].props.core_id =3D topo.core_id; ms->possible_cpus->cpus[i].props.has_thread_id =3D true; diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index c283dde0e9..7f50c9d83a 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -3114,6 +3114,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/target/i386/cpu.c b/target/i386/cpu.c index fac3cc028e..bd0f873883 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5865,11 +5865,13 @@ static Property x86_cpu_properties[] =3D { DEFINE_PROP_UINT32("apic-id", X86CPU, apic_id, 0), DEFINE_PROP_INT32("thread-id", X86CPU, thread_id, 0), DEFINE_PROP_INT32("core-id", X86CPU, core_id, 0), + DEFINE_PROP_INT32("die-id", X86CPU, die_id, 0), DEFINE_PROP_INT32("socket-id", X86CPU, socket_id, 0), #else DEFINE_PROP_UINT32("apic-id", X86CPU, apic_id, UNASSIGNED_APIC_ID), DEFINE_PROP_INT32("thread-id", X86CPU, thread_id, -1), DEFINE_PROP_INT32("core-id", X86CPU, core_id, -1), + DEFINE_PROP_INT32("die-id", X86CPU, die_id, -1), DEFINE_PROP_INT32("socket-id", X86CPU, socket_id, -1), #endif DEFINE_PROP_INT32("node-id", X86CPU, node_id, CPU_UNSET_NUMA_NODE_ID), --=20 2.18.0.rc1.1.g3f1ff2140