diff options
author | Keir Fraser <keir@xen.org> | 2011-01-07 14:13:15 +0000 |
---|---|---|
committer | Keir Fraser <keir@xen.org> | 2011-01-07 14:13:15 +0000 |
commit | e8dea77d35136724a441bebd6892cf35a6f90420 (patch) | |
tree | 035f348c49205ad94fa1578a536ed31907f80fe1 | |
parent | 94feecc881658cb925ce2243ff0786a372d3d9fa (diff) | |
download | xen-e8dea77d35136724a441bebd6892cf35a6f90420.tar.gz xen-e8dea77d35136724a441bebd6892cf35a6f90420.tar.bz2 xen-e8dea77d35136724a441bebd6892cf35a6f90420.zip |
ASID: Optimize hvm_flush_guest_tlbs
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>
-rw-r--r-- | xen/arch/x86/hvm/asid.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/xen/arch/x86/hvm/asid.c b/xen/arch/x86/hvm/asid.c index 183a3dcaf4..d6be9d1120 100644 --- a/xen/arch/x86/hvm/asid.c +++ b/xen/arch/x86/hvm/asid.c @@ -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; } /* |