WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] Re: [PATCH] FPU LWP 6/8: create lazy and non-lazy FPU re

To: Jan Beulich <JBeulich@xxxxxxxxxx>
Subject: Re: [Xen-devel] Re: [PATCH] FPU LWP 6/8: create lazy and non-lazy FPU restore functions
From: Wei Huang <wei.huang2@xxxxxxx>
Date: Thu, 5 May 2011 16:41:07 -0500
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>, KeirFraser <keir@xxxxxxx>
Delivery-date: Thu, 05 May 2011 14:48:34 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4DC26A46020000780003FC3E@xxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <4DC062ED.3070802@xxxxxxx> <4DC117D6020000780003F9CB@xxxxxxxxxxxxxxxxxx> <4DC17FF3.5080706@xxxxxxx> <4DC26A46020000780003FC3E@xxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10
Hi Jan,

If we want to make LWP restore optional in vcpu_restore_fpu_eager(), we have to change vcpu_save_fpu() as well. Otherwise, the extended state will become inconsistent for non-LWP VCPUs (because save and restore is asymmetric). There are two approaches:

1. In vcpu_save_fpu(), clean physical CPU's extended state for VCPU which is being scheduled in. This prevents messy states from causing problems. The disadvantage is the cleaning cost, which would out-weight the benefits. 2. Add a new variable in VCPU to track whether nonlazy state is dirty. I think this is better. See the attached file.

Let me know if it is what you want. After that, I will re-spin the patches.

Thanks,
-Wei


On 05/05/2011 02:13 AM, Jan Beulich wrote:
On 04.05.11 at 18:33, Wei Huang<wei.huang2@xxxxxxx>  wrote:
Checking whether there is a non-lazy state to save is architectural
specific and very messy. For instance, we need to read LWP_CBADDR to
confirm LWP's dirty state. This MSR is AMD specific and we don't want to
add it here. Plus reading data from LWP_CBADDR MSR might be as expensive
as clts/stts.

My previous email showed that the overhead with LWP is around 1%-2% of
__context_switch(). For non lwp-capable CPU, this overhead should be
much smaller (only clts and stts) because xfeature_mask[LWP] is 0.
I wasn't talking about determining whether LWP state is dirty, but
much rather about LWP not being in use at all.

Yes, clts() and stts() don't have to called every time. How about this one?

/* Restore FPU state whenever VCPU is schduled in. */
void vcpu_restore_fpu_eager(struct vcpu *v)
{
      ASSERT(!is_idle_vcpu(v));


      /* save the nonlazy extended state which is not tracked by CR0.TS bit */
      if ( xsave_enabled(v) )
      {
          /* Avoid recursion */
          clts();
          fpu_xrstor(v, XSTATE_NONLAZY);
          stts();
      }
That's certainly better, but I'd still like to see the xsave_enabled()
check to be replaced by some form of lwp_enabled() or
lazy_xsave_needed() or some such (which will at once exclude all
pv guests until you care to add support for them).

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


Attachment: nonlazy_dirty.txt
Description: nonlazy_dirty.txt

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel