All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Wang2 <wei.wang2@amd.com>
To: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: [RFC PATCH] ASID: Optimize hvm_flush_guest_tlbs
Date: Fri, 7 Jan 2011 13:52:07 +0100	[thread overview]
Message-ID: <201101071352.07595.wei.wang2@amd.com> (raw)

[-- 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

                 reply	other threads:[~2011-01-07 12:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201101071352.07595.wei.wang2@amd.com \
    --to=wei.wang2@amd.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.