]> xenbits.xensource.com Git - xen.git/commitdiff
ASID: Optimize hvm_flush_guest_tlbs
authorKeir Fraser <keir@xen.org>
Fri, 7 Jan 2011 14:13:15 +0000 (14:13 +0000)
committerKeir Fraser <keir@xen.org>
Fri, 7 Jan 2011 14:13:15 +0000 (14:13 +0000)
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.

Signed-off-by: Wei Wang <wei.wang2@amd.com>
Reviewed-by: Wei Huang <wei.huang2@amd.com>
Simplify the logic and also fix a very minor bug in
hvm_asid_handle_vmenter(), in the case that hvm_asid_flush_core() sets
data->disabled.

Signed-off-by: Keir Fraser <keir@xen.org>
xen/arch/x86/hvm/asid.c

index 183a3dcaf4bd48823785997b95fed84271406aa6..d6be9d11209bf294645f5554bb565cffb5c6e0ce 100644 (file)
@@ -100,10 +100,7 @@ void hvm_asid_flush_core(void)
         return;
 
     if ( likely(++data->core_asid_generation != 0) )
-    {
-        data->next_asid = 1;
         return;
-    }
 
     /*
      * ASID generations are 64 bit.  Overflow of generations never happens.
@@ -122,10 +119,7 @@ bool_t hvm_asid_handle_vmenter(void)
     /* On erratum #170 systems we must flush the TLB. 
      * Generation overruns are taken here, too. */
     if ( data->disabled )
-    {
-        curr->arch.hvm_vcpu.asid = 0;
-        return 0;
-    }
+        goto disabled;
 
     /* Test if VCPU has valid ASID. */
     if ( curr->arch.hvm_vcpu.asid_generation == data->core_asid_generation )
@@ -133,7 +127,12 @@ 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();
+        data->next_asid = 1;
+        if ( data->disabled )
+            goto disabled;
+    }
 
     /* Now guaranteed to be a free ASID. */
     curr->arch.hvm_vcpu.asid = data->next_asid++;
@@ -144,6 +143,10 @@ bool_t hvm_asid_handle_vmenter(void)
      * generation, and all old ASID allocations are now stale. 
      */
     return (curr->arch.hvm_vcpu.asid == 1);
+
+ disabled:
+    curr->arch.hvm_vcpu.asid = 0;
+    return 0;
 }
 
 /*