WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] x86/svm: eliminate unnecessary NR_CPUS-sized arrays

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] x86/svm: eliminate unnecessary NR_CPUS-sized arrays
From: "Jan Beulich" <JBeulich@xxxxxxxxxx>
Date: Thu, 08 Jul 2010 16:34:48 +0100
Delivery-date: Thu, 08 Jul 2010 08:34:47 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Replace them with per-CPU data.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>

--- 2010-06-15.orig/xen/arch/x86/hvm/svm/svm.c  2010-06-14 08:49:36.000000000 
+0200
+++ 2010-06-15/xen/arch/x86/hvm/svm/svm.c       2010-07-06 15:09:06.000000000 
+0200
@@ -68,10 +68,10 @@ static struct hvm_function_table svm_fun
 enum handler_return { HNDL_done, HNDL_unhandled, HNDL_exception_raised };
 
 /* va of hardware host save area     */
-static void *hsa[NR_CPUS] __read_mostly;
+static DEFINE_PER_CPU_READ_MOSTLY(void *, hsa);
 
 /* vmcb used for extended host state */
-static void *root_vmcb[NR_CPUS] __read_mostly;
+static DEFINE_PER_CPU_READ_MOSTLY(void *, root_vmcb);
 
 static bool_t amd_erratum383_found __read_mostly;
 
@@ -643,7 +643,7 @@ static void svm_ctxt_switch_from(struct 
     vpmu_save(v);
 
     svm_sync_vmcb(v);
-    svm_vmload(root_vmcb[cpu]);
+    svm_vmload(per_cpu(root_vmcb, cpu));
 
 #ifdef __x86_64__
     /* Resume use of ISTs now that the host TR is reinstated. */
@@ -679,7 +679,7 @@ static void svm_ctxt_switch_to(struct vc
 
     svm_restore_dr(v);
 
-    svm_vmsave(root_vmcb[cpu]);
+    svm_vmsave(per_cpu(root_vmcb, cpu));
     svm_vmload(v->arch.hvm_svm.vmcb);
     vpmu_load(v);
 
@@ -821,18 +821,18 @@ static int svm_do_pmu_interrupt(struct c
 
 static void svm_cpu_dead(unsigned int cpu)
 {
-    free_xenheap_page(hsa[cpu]);
-    hsa[cpu] = NULL;
-    free_vmcb(root_vmcb[cpu]);
-    root_vmcb[cpu] = NULL;
+    free_xenheap_page(per_cpu(hsa, cpu));
+    per_cpu(hsa, cpu) = NULL;
+    free_vmcb(per_cpu(root_vmcb, cpu));
+    per_cpu(root_vmcb, cpu) = NULL;
 }
 
 static int svm_cpu_up_prepare(unsigned int cpu)
 {
-    if ( ((hsa[cpu] == NULL) &&
-          ((hsa[cpu] = alloc_host_save_area()) == NULL)) ||
-         ((root_vmcb[cpu] == NULL) &&
-          ((root_vmcb[cpu] = alloc_vmcb()) == NULL)) )
+    if ( ((per_cpu(hsa, cpu) == NULL) &&
+          ((per_cpu(hsa, cpu) = alloc_host_save_area()) == NULL)) ||
+         ((per_cpu(root_vmcb, cpu) == NULL) &&
+          ((per_cpu(root_vmcb, cpu) = alloc_vmcb()) == NULL)) )
     {
         svm_cpu_dead(cpu);
         return -ENOMEM;
@@ -880,7 +880,7 @@ static int svm_cpu_up(void)
     write_efer(read_efer() | EFER_SVME);
 
     /* Initialize the HSA for this core. */
-    wrmsrl(MSR_K8_VM_HSAVE_PA, (uint64_t)virt_to_maddr(hsa[cpu]));
+    wrmsrl(MSR_K8_VM_HSAVE_PA, (uint64_t)virt_to_maddr(per_cpu(hsa, cpu)));
 
     /* check for erratum 383 */
     svm_init_erratum_383(c);



Attachment: svm-no-NR_CPUS.patch
Description: Text document

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] x86/svm: eliminate unnecessary NR_CPUS-sized arrays, Jan Beulich <=