From: Keir Fraser Date: Fri, 7 Jan 2011 14:13:15 +0000 (+0000) Subject: ASID: Optimize hvm_flush_guest_tlbs X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~10970 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=e8dea77d35136724a441bebd6892cf35a6f90420;p=xen.git 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 Reviewed-by: Wei Huang 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 --- 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; } /*