From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Wang2 Subject: [RFC PATCH] ASID: Optimize hvm_flush_guest_tlbs Date: Fri, 7 Jan 2011 13:52:07 +0100 Message-ID: <201101071352.07595.wei.wang2@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary-00=_3xwJN7Y5hcNWfzw" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org --Boundary-00=_3xwJN7Y5hcNWfzw Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi In our testing, we found that function hvm_flush_guest_tlbs() is used very= =20 frequently and it will always force asid recycling and will result a whole= =20 tlb flush immediately no matter there are still free asids or not. Actuall= y,=20 in this case, just increasing core generation might be enough and the=20 remaining asids can still be used until next_asid > max_asid. Thanks, Wei Signed-off-by: Wei Wang Reviewed-by: Wei Huang =2D-=20 Advanced Micro Devices GmbH Sitz: Dornach, Gemeinde Aschheim,=20 Landkreis M=FCnchen Registergericht M=FCnchen,=20 HRB Nr. 43632 WEEE-Reg-Nr: DE 12919551 Gesch=E4ftsf=FChrer: Alberto Bozzo, Andrew Bowd --Boundary-00=_3xwJN7Y5hcNWfzw Content-Type: text/x-diff; charset="iso-8859-1"; name="opt_asid.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="opt_asid.patch" Content-Description: opt_asid.patch 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, --Boundary-00=_3xwJN7Y5hcNWfzw Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --Boundary-00=_3xwJN7Y5hcNWfzw--