All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	qemu-devel@nongnu.org,
	Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
	Richard Henderson <rth@twiddle.net>
Cc: Like Xu <like.xu@linux.intel.com>
Subject: [Qemu-devel] [PULL v6 13/42] i386/cpu: Consolidate die-id validity in smp context
Date: Fri,  5 Jul 2019 19:14:35 -0300	[thread overview]
Message-ID: <20190705221504.25166-14-ehabkost@redhat.com> (raw)
In-Reply-To: <20190705221504.25166-1-ehabkost@redhat.com>

From: Like Xu <like.xu@linux.intel.com>

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 <dgilbert@redhat.com>
Signed-off-by: Like Xu <like.xu@linux.intel.com>
Message-Id: <20190612084104.34984-4-like.xu@linux.intel.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 qapi/machine.json          |  7 ++++---
 include/hw/i386/topology.h |  2 ++
 target/i386/cpu.h          |  1 +
 hw/core/machine-hmp-cmds.c |  3 +++
 hw/core/machine.c          | 12 ++++++++++++
 hw/i386/pc.c               | 14 ++++++++++++++
 target/i386/cpu.c          |  2 ++
 7 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/qapi/machine.json b/qapi/machine.json
index 81849acb3a..979bc41e49 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -588,10 +588,10 @@
 #
 # @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
-# @thread-id: thread number within core 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
@@ -602,6 +602,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;
 
 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 apicid,
     topo->core_id = (apicid >> apicid_core_offset(nr_cores, nr_threads)) &
                    ~(0xFFFFFFFFUL << apicid_core_width(nr_cores, nr_threads));
     topo->pkg_id = apicid >> apicid_pkg_offset(nr_cores, nr_threads);
+    topo->die_id = 0;
 }
 
 /* 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 {
 
     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;
 
diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c
index 7fa6075f1e..1f66bda346 100644
--- a/hw/core/machine-hmp-cmds.c
+++ b/hw/core/machine-hmp-cmds.c
@@ -86,6 +86,9 @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict)
         if (c->has_socket_id) {
             monitor_printf(mon, "    socket-id: \"%" PRIu64 "\"\n", c->socket_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 ea84bd6788..b35dea05bd 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -683,6 +683,11 @@ void machine_set_cpu_numa_node(MachineState *machine,
             return;
         }
 
+        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 != slot->props.thread_id) {
                 continue;
@@ -692,6 +697,10 @@ void machine_set_cpu_numa_node(MachineState *machine,
                 continue;
         }
 
+        if (props->has_die_id && props->die_id != slot->props.die_id) {
+                continue;
+        }
+
         if (props->has_socket_id && props->socket_id != slot->props.socket_id) {
                 continue;
         }
@@ -949,6 +958,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 4dac96860d..f91ff5e06e 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -2324,6 +2324,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");
@@ -2343,6 +2347,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev,
         }
 
         topo.pkg_id = cpu->socket_id;
+        topo.die_id = cpu->die_id;
         topo.core_id = cpu->core_id;
         topo.smt_id = cpu->thread_id;
         cpu->apic_id = apicid_from_topo_ids(smp_cores, smp_threads, &topo);
@@ -2380,6 +2385,13 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev,
     }
     cpu->socket_id = topo.pkg_id;
 
+    if (cpu->die_id != -1 && cpu->die_id != 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 = topo.die_id;
+
     if (cpu->core_id != -1 && cpu->core_id != 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_id);
@@ -2766,6 +2778,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 = true;
         ms->possible_cpus->cpus[i].props.socket_id = topo.pkg_id;
+        ms->possible_cpus->cpus[i].props.has_die_id = true;
+        ms->possible_cpus->cpus[i].props.die_id = topo.die_id;
         ms->possible_cpus->cpus[i].props.has_core_id = true;
         ms->possible_cpus->cpus[i].props.core_id = topo.core_id;
         ms->possible_cpus->cpus[i].props.has_thread_id = true;
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 8ef3063140..6b3d0035e0 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -5865,11 +5865,13 @@ static Property x86_cpu_properties[] = {
     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),
-- 
2.18.0.rc1.1.g3f1ff2140



  parent reply	other threads:[~2019-07-05 22:24 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-05 22:14 [Qemu-devel] [PULL v6 00/42] Machine and x86 queue, 2019-07-05 Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 01/42] hw/boards: Add struct CpuTopology to MachineState Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 02/42] machine: Refactor smp-related call chains to pass MachineState Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 03/42] general: Replace global smp variables with smp machine properties Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 04/42] hw/ppc: Replace global smp variables with machine smp properties Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 05/42] hw/riscv: " Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 06/42] hw/s390x: " Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 07/42] hw/i386: " Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 08/42] hw/arm: " Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 09/42] hw: Replace global smp variables with MachineState for all remaining archs Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 10/42] vl.c: Replace smp global variables with smp machine properties Eduardo Habkost
2019-07-08 14:56   ` Laurent Desnogues
2019-07-08 20:40     ` Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 11/42] i386: Add die-level cpu topology to x86CPU on PCMachine Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 12/42] hw/i386: Adjust nr_dies with configured smp_dies for PCMachine Eduardo Habkost
2019-07-05 22:14 ` Eduardo Habkost [this message]
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 14/42] i386: Update new x86_apicid parsing rules with die_offset support Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 15/42] pc: fix possible NULL pointer dereference in pc_machine_get_device_memory_region_size() Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 16/42] machine: show if CLI option '-numa node, mem' is supported in QAPI schema Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 17/42] numa: deprecate 'mem' parameter of '-numa node' option Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 18/42] numa: deprecate implict memory distribution between nodes Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 19/42] hppa: Delete unused hppa_cpu_list() function Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 20/42] deprecate -mem-path fallback to anonymous RAM Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 21/42] i386: Don't print warning if phys-bits was set automatically Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 22/42] i386: Fix signedness of hyperv_spinlock_attempts Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 23/42] i386: make 'hv-spinlocks' a regular uint32 property Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 24/42] x86/cpu: use FeatureWordArray to define filtered_features Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 25/42] i386: Remove unused host_cpudef variable Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 26/42] target/i386: Add CPUID.1F generation support for multi-dies PCMachine Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 27/42] machine: Refactor smp_parse() in vl.c as MachineClass::smp_parse() Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 28/42] vl.c: Add -smp, dies=* command line support and update doc Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 29/42] qmp: Add deprecation information to query-machines Eduardo Habkost
2019-07-08 13:29   ` Eric Blake
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 30/42] i386: Introduce SnowRidge CPU model Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 31/42] qmp: Add "alias-of" field to query-cpu-definitions Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 32/42] i386: Add x-force-features option for testing Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 33/42] i386: Get model-id from CPU object on "-cpu help" Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 34/42] i386: Register versioned CPU models Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 35/42] i386: Define -IBRS, -noTSX, -IBRS versions of " Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 36/42] i386: Replace -noTSX, -IBRS, -IBPB CPU models with aliases Eduardo Habkost
2019-07-05 22:14 ` [Qemu-devel] [PULL v6 37/42] i386: Make unversioned CPU models be aliases Eduardo Habkost
2019-07-05 22:15 ` [Qemu-devel] [PULL v6 38/42] docs: Deprecate CPU model runnability guarantees Eduardo Habkost
2019-07-05 22:15 ` [Qemu-devel] [PULL v6 39/42] i386: Add Cascadelake-Server-v2 CPU model Eduardo Habkost
2019-07-05 22:15 ` [Qemu-devel] [PULL v6 40/42] numa: Make deprecation warnings conditional on !qtest_enabled() Eduardo Habkost
2019-07-05 22:15 ` [Qemu-devel] [PULL v6 41/42] numa: allow memory-less nodes when using memdev as backend Eduardo Habkost
2019-07-05 22:15 ` [Qemu-devel] [PULL v6 42/42] tests: use -numa memdev option in tests instead of legacy 'mem' option Eduardo Habkost
2019-07-06  6:46 ` [Qemu-devel] [PULL v6 00/42] Machine and x86 queue, 2019-07-05 no-reply
2019-07-08  9:26 ` Peter Maydell
2019-07-08 12:44   ` Igor Mammedov

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=20190705221504.25166-14-ehabkost@redhat.com \
    --to=ehabkost@redhat.com \
    --cc=like.xu@linux.intel.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.