All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] ASID: Optimize hvm_flush_guest_tlbs
@ 2011-01-07 12:52 Wei Wang2
  0 siblings, 0 replies; only message in thread
From: Wei Wang2 @ 2011-01-07 12:52 UTC (permalink / raw)
  To: xen-devel@lists.xensource.com

[-- Attachment #1: Type: text/plain, Size: 681 bytes --]

Hi
In our testing, we found that function hvm_flush_guest_tlbs() is used very 
frequently and it will always force asid recycling and will result a whole 
tlb flush immediately no matter there are still free asids or not.  Actually, 
in this case, just increasing core generation might be enough and the 
remaining asids can still be used until  next_asid > max_asid.
Thanks,
Wei

Signed-off-by: Wei Wang <wei.wang2@amd.com>
Reviewed-by: Wei Huang<wei.huang2@amd.com>
-- 
Advanced Micro Devices GmbH
Sitz: Dornach, Gemeinde Aschheim, 
Landkreis München Registergericht München, 
HRB Nr. 43632
WEEE-Reg-Nr: DE 12919551
Geschäftsführer:
Alberto Bozzo, Andrew Bowd

[-- Attachment #2: opt_asid.patch --]
[-- Type: text/x-diff, Size: 2460 bytes --]

diff -r cb756381087c xen/arch/x86/hvm/asid.c
--- a/xen/arch/x86/hvm/asid.c	Thu Jan 06 19:02:36 2011 +0000
+++ b/xen/arch/x86/hvm/asid.c	Fri Jan 07 10:59:14 2011 +0100
@@ -68,7 +68,7 @@ void hvm_asid_init(int nasids)
      * exist that reference earlier generations on this CPU.
      */
     if ( test_and_set_bool(data->initialised) )
-        return hvm_asid_flush_core();
+        return hvm_asid_flush_core(1);
 
     data->max_asid = nasids - 1;
     data->disabled = (nasids <= 1);
@@ -92,7 +92,7 @@ void hvm_asid_flush_vcpu(struct vcpu *v)
     v->arch.hvm_vcpu.asid_generation = 0;
 }
 
-void hvm_asid_flush_core(void)
+void hvm_asid_flush_core(bool_t force_recycle)
 {
     struct hvm_asid_data *data = &this_cpu(hvm_asid_data);
 
@@ -101,7 +101,8 @@ void hvm_asid_flush_core(void)
 
     if ( likely(++data->core_asid_generation != 0) )
     {
-        data->next_asid = 1;
+        if ( force_recycle )
+            data->next_asid = 1;
         return;
     }
 
@@ -133,7 +134,7 @@ bool_t hvm_asid_handle_vmenter(void)
 
     /* If there are no free ASIDs, need to go to a new generation */
     if ( unlikely(data->next_asid > data->max_asid) )
-        hvm_asid_flush_core();
+        hvm_asid_flush_core(1);
 
     /* Now guaranteed to be a free ASID. */
     curr->arch.hvm_vcpu.asid = data->next_asid++;
diff -r cb756381087c xen/include/asm-x86/hvm/asid.h
--- a/xen/include/asm-x86/hvm/asid.h	Thu Jan 06 19:02:36 2011 +0000
+++ b/xen/include/asm-x86/hvm/asid.h	Fri Jan 07 10:59:14 2011 +0100
@@ -30,8 +30,8 @@ void hvm_asid_init(int nasids);
 /* Invalidate a VCPU's current ASID allocation: forces re-allocation. */
 void hvm_asid_flush_vcpu(struct vcpu *v);
 
-/* Flush all ASIDs on this processor core. */
-void hvm_asid_flush_core(void);
+/* Increase core generation, force ASID recycling when necessary. */
+void hvm_asid_flush_core(bool_t force_recycle);
 
 /* Called before entry to guest context. Checks ASID allocation, returns a
  * boolean indicating whether all ASIDs must be flushed. */
diff -r cb756381087c xen/include/asm-x86/hvm/hvm.h
--- a/xen/include/asm-x86/hvm/hvm.h	Thu Jan 06 19:02:36 2011 +0000
+++ b/xen/include/asm-x86/hvm/hvm.h	Fri Jan 07 10:59:14 2011 +0100
@@ -227,7 +227,7 @@ static inline void hvm_flush_guest_tlbs(
 static inline void hvm_flush_guest_tlbs(void)
 {
     if ( hvm_enabled )
-        hvm_asid_flush_core();
+        hvm_asid_flush_core(0);
 }
 
 void hvm_hypercall_page_initialise(struct domain *d,

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-01-07 12:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-07 12:52 [RFC PATCH] ASID: Optimize hvm_flush_guest_tlbs Wei Wang2

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.