debuggers.hg

changeset 22722:82c205df4406

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>
author Keir Fraser <keir@xen.org>
date Fri Jan 07 14:13:15 2011 +0000 (2011-01-07)
parents 0ab058a55c24
children 7932a9452b4f
files xen/arch/x86/hvm/asid.c
line diff
     1.1 --- a/xen/arch/x86/hvm/asid.c	Fri Jan 07 13:30:04 2011 +0000
     1.2 +++ b/xen/arch/x86/hvm/asid.c	Fri Jan 07 14:13:15 2011 +0000
     1.3 @@ -100,10 +100,7 @@ void hvm_asid_flush_core(void)
     1.4          return;
     1.5  
     1.6      if ( likely(++data->core_asid_generation != 0) )
     1.7 -    {
     1.8 -        data->next_asid = 1;
     1.9          return;
    1.10 -    }
    1.11  
    1.12      /*
    1.13       * ASID generations are 64 bit.  Overflow of generations never happens.
    1.14 @@ -122,10 +119,7 @@ bool_t hvm_asid_handle_vmenter(void)
    1.15      /* On erratum #170 systems we must flush the TLB. 
    1.16       * Generation overruns are taken here, too. */
    1.17      if ( data->disabled )
    1.18 -    {
    1.19 -        curr->arch.hvm_vcpu.asid = 0;
    1.20 -        return 0;
    1.21 -    }
    1.22 +        goto disabled;
    1.23  
    1.24      /* Test if VCPU has valid ASID. */
    1.25      if ( curr->arch.hvm_vcpu.asid_generation == data->core_asid_generation )
    1.26 @@ -133,7 +127,12 @@ bool_t hvm_asid_handle_vmenter(void)
    1.27  
    1.28      /* If there are no free ASIDs, need to go to a new generation */
    1.29      if ( unlikely(data->next_asid > data->max_asid) )
    1.30 +    {
    1.31          hvm_asid_flush_core();
    1.32 +        data->next_asid = 1;
    1.33 +        if ( data->disabled )
    1.34 +            goto disabled;
    1.35 +    }
    1.36  
    1.37      /* Now guaranteed to be a free ASID. */
    1.38      curr->arch.hvm_vcpu.asid = data->next_asid++;
    1.39 @@ -144,6 +143,10 @@ bool_t hvm_asid_handle_vmenter(void)
    1.40       * generation, and all old ASID allocations are now stale. 
    1.41       */
    1.42      return (curr->arch.hvm_vcpu.asid == 1);
    1.43 +
    1.44 + disabled:
    1.45 +    curr->arch.hvm_vcpu.asid = 0;
    1.46 +    return 0;
    1.47  }
    1.48  
    1.49  /*