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

[Xen-devel] [PATCH][retry 3][1/2] new vcpu op call to get physical CPU information



Some AMD machines have APIC IDs that not equal to CPU IDs.  In
the default Xen configuration, ACPI calls on these machines
can get confused.  This shows up most noticeably when running
AMD PowerNow!.  The only solution is for dom0 to get the
hypervisor's cpuid to apicid table when needed (ie, when dom0
vcpus are pinned).

Add a vcpu op to Xen to allow dom0 to query the
hypervisor for architecture dependent physical cpu information
if dom0 vcpus are pinned.  

The second patch adds the dom0 call to this vcpu hypercall.

I have tested this on my 4p/16 core machine and it works.  I
would appreciate testing on other boxes.

-Mark Langsdorf
Operating System Research Center
AMD

Signed-off-by: Mark Langsdorf <mark.langsdorf@xxxxxxx>
diff -r 7530c4dba8a5 xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c     Mon Mar 03 15:19:39 2008 +0000
+++ b/xen/arch/x86/domain.c     Tue Mar 04 15:42:51 2008 -0600
@@ -952,6 +952,30 @@ arch_do_vcpu_op(
         break;
     }
 
+    case VCPUOP_get_physid:
+    {
+        struct vcpu_get_physid cpu_id;
+        int i;
+        int cpu_num = v->vcpu_id;
+       short temp = 0xff;
+
+        if ( !opt_dom0_vcpus_pin)
+            rc = -EINVAL;
+        rc = -EFAULT;
+
+        cpu_id.phys_id = x86_cpu_to_apicid[cpu_num];
+        for (i = 0; i++; i < NR_CPUS) 
+             if (x86_acpiid_to_apicid[i] == x86_cpu_to_apicid[cpu_num])
+                 temp = i;
+       cpu_id.phys_id |= temp << 8;
+
+        if ( copy_to_guest(arg, &cpu_id, 1) )
+            break;
+        rc = 0;
+
+        break;
+    }
+
     default:
         rc = -ENOSYS;
         break;
diff -r 7530c4dba8a5 xen/common/schedule.c
--- a/xen/common/schedule.c     Mon Mar 03 15:19:39 2008 +0000
+++ b/xen/common/schedule.c     Tue Mar 04 15:42:51 2008 -0600
@@ -39,7 +39,8 @@ string_param("sched", opt_sched);
 string_param("sched", opt_sched);
 
 /* opt_dom0_vcpus_pin: If true, dom0 VCPUs are pinned. */
-static unsigned int opt_dom0_vcpus_pin;
+unsigned int opt_dom0_vcpus_pin;
+EXPORT_SYMBOL(opt_dom0_vcpus_pin);
 boolean_param("dom0_vcpus_pin", opt_dom0_vcpus_pin);
 
 enum cpufreq_controller cpufreq_controller;
diff -r 7530c4dba8a5 xen/include/public/vcpu.h
--- a/xen/include/public/vcpu.h Mon Mar 03 15:19:39 2008 +0000
+++ b/xen/include/public/vcpu.h Tue Mar 04 15:42:51 2008 -0600
@@ -182,6 +182,17 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_register_vc
 /* Send an NMI to the specified VCPU. @extra_arg == NULL. */
 #define VCPUOP_send_nmi             11
 
+/* 
+ * Get the physical ID information for a pinned vcpu's underlying
+ * physical processor.  The phyiscal ID informmation is architecture
+ * defined, but would ACPI and APIC IDs on x86 processors.
+ */
+#define VCPUOP_get_physid           12 /* arg == vcpu_get_physid_t */
+struct vcpu_get_physid {
+    uint64_t phys_id;
+};
+typedef struct vcpu_get_physid vcpu_get_physid_t;
+DEFINE_XEN_GUEST_HANDLE(vcpu_get_physid_t);
 #endif /* __XEN_PUBLIC_VCPU_H__ */
 
 /*
diff -r 7530c4dba8a5 xen/include/xen/sched.h
--- a/xen/include/xen/sched.h   Mon Mar 03 15:19:39 2008 +0000
+++ b/xen/include/xen/sched.h   Tue Mar 04 15:42:51 2008 -0600
@@ -29,6 +29,9 @@ extern unsigned long volatile jiffies;
 
 /* A global pointer to the initial domain (DOM0). */
 extern struct domain *dom0;
+
+/* opt_dom0_vcpus_pin: If true, dom0 VCPUs are pinned. */
+extern unsigned int opt_dom0_vcpus_pin;
 
 #ifndef CONFIG_COMPAT
 #define MAX_EVTCHNS(d)     NR_EVENT_CHANNELS


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

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