x86: don't use BAD_APICID for non-APICID fields
authorBoris Ostrovsky <boris.ostrovsky@oracle.com>
Tue, 24 Mar 2015 08:27:00 +0000 (09:27 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 24 Mar 2015 08:27:00 +0000 (09:27 +0100)
BAD_APICID is used by cpuinfo_x86's phys_proc_id, cpu_core_id
and compute_unit_id even though these fields don't hold an APIC ID
itself but rather its derivative.

Provide appropriate macros for each of those three (and make them
unsigned).

This also fixes regression introduced by commit 2090f14c5cbd ("sysctl:
make XEN_SYSCTL_topologyinfo sysctl a little more efficient") which
leaked BAD_APICID into common code, breaking ARM.

Reported-by: Julien Grall <julien.grall@linaro.org>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Ditch INVALID_{CORE,SOCKET}ID in favor of always using
XEN_INVALID_{CORE,SOCKET}_ID.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/cpu/common.c
xen/arch/x86/smpboot.c
xen/common/sched_credit2.c
xen/common/sysctl.c
xen/include/asm-x86/processor.h
xen/include/asm-x86/smp.h

index 5c8d3c251e2d31b0fa40ea8826f43a7d0d5070ff..53dbd8418161b6dd34d802f80dd552e18daa424d 100644 (file)
@@ -12,6 +12,7 @@
 #include <asm/apic.h>
 #include <mach_apic.h>
 #include <asm/setup.h>
+#include <public/sysctl.h> /* for XEN_INVALID_{SOCKET,CORE}_ID */
 
 #include "cpu.h"
 
@@ -277,9 +278,9 @@ void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
        c->x86_max_cores = 1;
        c->x86_num_siblings = 1;
        c->x86_clflush_size = 0;
-       c->phys_proc_id = BAD_APICID;
-       c->cpu_core_id = BAD_APICID;
-       c->compute_unit_id = BAD_APICID;
+       c->phys_proc_id = XEN_INVALID_SOCKET_ID;
+       c->cpu_core_id = XEN_INVALID_CORE_ID;
+       c->compute_unit_id = INVALID_CUID;
        memset(&c->x86_capability, 0, sizeof c->x86_capability);
 
        generic_identify(c);
index 314e2535a84eb8604ce51c81de1edc447c49e625..d3fe116cd6827642cf851d0d9208f5fe7ea98e9a 100644 (file)
@@ -792,9 +792,9 @@ remove_siblinginfo(int cpu)
         cpumask_clear_cpu(cpu, per_cpu(cpu_sibling_mask, sibling));
     cpumask_clear(per_cpu(cpu_sibling_mask, cpu));
     cpumask_clear(per_cpu(cpu_core_mask, cpu));
-    c[cpu].phys_proc_id = BAD_APICID;
-    c[cpu].cpu_core_id = BAD_APICID;
-    c[cpu].compute_unit_id = BAD_APICID;
+    c[cpu].phys_proc_id = XEN_INVALID_SOCKET_ID;
+    c[cpu].cpu_core_id = XEN_INVALID_CORE_ID;
+    c[cpu].compute_unit_id = INVALID_CUID;
     cpumask_clear_cpu(cpu, &cpu_sibling_setup_map);
 }
 
index be6859a6b73360c0cdc3ff043f18e97988fa5c0c..90f85a2598c3c361bc26973354de121540552d6b 100644 (file)
@@ -1952,7 +1952,7 @@ static void deactivate_runqueue(struct csched2_private *prv, int rqi)
 
 static void init_pcpu(const struct scheduler *ops, int cpu)
 {
-    int rqi;
+    unsigned rqi;
     unsigned long flags;
     struct csched2_private *prv = CSCHED2_PRIV(ops);
     struct csched2_runqueue_data *rqd;
@@ -1977,7 +1977,7 @@ static void init_pcpu(const struct scheduler *ops, int cpu)
     else
         rqi = cpu_to_socket(cpu);
 
-    if ( rqi < 0 )
+    if ( rqi == XEN_INVALID_SOCKET_ID )
     {
         printk("%s: cpu_to_socket(%d) returned %d!\n",
                __func__, cpu, rqi);
@@ -2020,7 +2020,7 @@ csched2_alloc_pdata(const struct scheduler *ops, int cpu)
 {
     /* Check to see if the cpu is online yet */
     /* Note: cpu 0 doesn't get a STARTING callback */
-    if ( cpu == 0 || cpu_to_socket(cpu) >= 0 )
+    if ( cpu == 0 || cpu_to_socket(cpu) != XEN_INVALID_SOCKET_ID )
         init_pcpu(ops, cpu);
     else
         printk("%s: cpu %d not online yet, deferring initializatgion\n",
index fc7b3d59b0c6cea43872ea8630ae212d026c983e..a8c629f38de9840b06fa1bbf3feb5b46ff2f3d7b 100644 (file)
@@ -346,11 +346,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
                 if ( cpu_present(i) )
                 {
                     cputopo.core = cpu_to_core(i);
-                    if ( cputopo.core == BAD_APICID )
-                        cputopo.core = XEN_INVALID_CORE_ID;
                     cputopo.socket = cpu_to_socket(i);
-                    if ( cputopo.socket == BAD_APICID )
-                        cputopo.socket = XEN_INVALID_SOCKET_ID;
                     cputopo.node = cpu_to_node(i);
                     if ( cputopo.node == NUMA_NO_NODE )
                         cputopo.node = XEN_INVALID_NODE_ID;
index 87d80ffe69638a2d5d28e8a12e3cb095046e0302..a9b4e06cf41ea9167c0a06e25200f0f4124ef586 100644 (file)
@@ -180,9 +180,9 @@ struct cpuinfo_x86 {
     __u32 booted_cores;  /* number of cores as seen by OS */
     __u32 x86_num_siblings; /* cpuid logical cpus per chip value */
     __u32 apicid;
-    int   phys_proc_id; /* package ID of each logical CPU */
-    int   cpu_core_id; /* core ID of each logical CPU*/
-    int   compute_unit_id; /* AMD compute unit ID of each logical CPU */
+    __u32 phys_proc_id;    /* package ID of each logical CPU */
+    __u32 cpu_core_id;     /* core ID of each logical CPU*/
+    __u32 compute_unit_id; /* AMD compute unit ID of each logical CPU */
     unsigned short x86_clflush_size;
 } __cacheline_aligned;
 
index 81f861005e120d27b889e0b95afc12bab812c6bd..67518cf30b07f4994c463108446961251798dca5 100644 (file)
@@ -16,7 +16,8 @@
 #include <asm/mpspec.h>
 #endif
 
-#define BAD_APICID -1U
+#define BAD_APICID   (-1U)
+#define INVALID_CUID (~0U)   /* AMD Compute Unit ID */
 #ifndef __ASSEMBLY__
 
 /*