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

[Xen-devel] [PATCH 1/2] add cpu_thread_id to struct cpuinfo_x86



Add the thread-id to the cpu config data and an accessor macro
cpu_to_thread().

Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
 xen/arch/x86/cpu/common.c       |  1 +
 xen/arch/x86/smpboot.c          | 10 ++++++++++
 xen/include/asm-arm/processor.h |  1 +
 xen/include/asm-x86/processor.h |  2 ++
 xen/include/public/sysctl.h     |  1 +
 5 files changed, 15 insertions(+)

diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
index 057859ab14..f626a6a510 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -434,6 +434,7 @@ void identify_cpu(struct cpuinfo_x86 *c)
        c->phys_proc_id = XEN_INVALID_SOCKET_ID;
        c->cpu_core_id = XEN_INVALID_CORE_ID;
        c->compute_unit_id = INVALID_CUID;
+       c->cpu_thread_id = XEN_INVALID_THREAD_ID;
        memset(&c->x86_capability, 0, sizeof c->x86_capability);
 
        generic_identify(c);
diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c
index 7e76cc3d68..2c6a40c543 100644
--- a/xen/arch/x86/smpboot.c
+++ b/xen/arch/x86/smpboot.c
@@ -247,6 +247,8 @@ static void set_cpu_sibling_map(unsigned int cpu)
     cpumask_set_cpu(cpu, per_cpu(cpu_core_mask, cpu));
     cpumask_set_cpu(cpu, per_cpu(cpu_sibling_mask, cpu));
 
+    c[cpu].cpu_thread_id = 0;
+
     if ( c[cpu].x86_num_siblings > 1 )
     {
         for_each_cpu ( i, &cpu_sibling_setup_map )
@@ -270,6 +272,14 @@ static void set_cpu_sibling_map(unsigned int cpu)
                        "CPU%u: unclear relationship with CPU%u\n",
                        cpu, i);
         }
+
+        for_each_cpu ( i, per_cpu(cpu_sibling_mask, cpu) )
+        {
+            if ( cpu == i )
+                break;
+            c[cpu].cpu_thread_id++;
+        }
+
     }
 
     if ( c[cpu].x86_max_cores == 1 )
diff --git a/xen/include/asm-arm/processor.h b/xen/include/asm-arm/processor.h
index 222a02dd99..fbfbe1962c 100644
--- a/xen/include/asm-arm/processor.h
+++ b/xen/include/asm-arm/processor.h
@@ -801,6 +801,7 @@ void show_registers(struct cpu_user_regs *regs);
 #define cpu_relax() barrier() /* Could yield? */
 
 /* All a bit UP for the moment */
+#define cpu_to_thread(_cpu) (0)
 #define cpu_to_core(_cpu)   (0)
 #define cpu_to_socket(_cpu) (0)
 
diff --git a/xen/include/asm-x86/processor.h b/xen/include/asm-x86/processor.h
index a166802344..850d8f50f0 100644
--- a/xen/include/asm-x86/processor.h
+++ b/xen/include/asm-x86/processor.h
@@ -134,6 +134,7 @@ struct cpuinfo_x86 {
     __u32 apicid;
     __u32 phys_proc_id;    /* package ID of each logical CPU */
     __u32 cpu_core_id;     /* core ID of each logical CPU*/
+    __u32 cpu_thread_id;   /* thread ID of each logical CPU */
     __u32 compute_unit_id; /* AMD compute unit ID of each logical CPU */
     unsigned short x86_clflush_size;
 } __cacheline_aligned;
@@ -174,6 +175,7 @@ extern void detect_extended_topology(struct cpuinfo_x86 *c);
 
 extern void detect_ht(struct cpuinfo_x86 *c);
 
+#define cpu_to_thread(_cpu) (cpu_data[_cpu].cpu_thread_id)
 #define cpu_to_core(_cpu)   (cpu_data[_cpu].cpu_core_id)
 #define cpu_to_socket(_cpu) (cpu_data[_cpu].phys_proc_id)
 
diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h
index 839c1b9f25..e439e00983 100644
--- a/xen/include/public/sysctl.h
+++ b/xen/include/public/sysctl.h
@@ -434,6 +434,7 @@ struct xen_sysctl_lockprof_op {
 };
 
 /* XEN_SYSCTL_cputopoinfo */
+#define XEN_INVALID_THREAD_ID   (~0U)
 #define XEN_INVALID_CORE_ID     (~0U)
 #define XEN_INVALID_SOCKET_ID   (~0U)
 #define XEN_INVALID_NODE_ID     (~0U)
-- 
2.16.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.