ASID: Optimize hvm_flush_guest_tlbs
RFC PATCH 1/1 ASID: Optimize hvm_flush_guest_tlbs
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 <[email protected]>
Reviewed-by Wei Huang<[email protected]>
Signature · 7 lines
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
xen/arch/x86/hvm/asid.c +5 -4
@@ -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++;
xen/include/asm-x86/hvm/asid.h +2 -2
@@ -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. */
xen/include/asm-x86/hvm/hvm.h +1 -1
@@ -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,
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel