Received: by 10.223.164.202 with SMTP id h10csp711043wrb; Wed, 15 Nov 2017 06:45:42 -0800 (PST) X-Google-Smtp-Source: AGs4zMYzItv06oWupmzhkXWYSFGsfdJbyfi+KTUoF/vizNeeIi7kcJ70jf5vA1+bq0/ZMacQYrMO X-Received: by 10.98.50.193 with SMTP id y184mr17938421pfy.9.1510757142031; Wed, 15 Nov 2017 06:45:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510757141; cv=none; d=google.com; s=arc-20160816; b=S6j5X2sFkhrpd3oW5PJgyNuzZY0XAwsUxxqOVugHm7PT5+Up/zQ5Uqftl2/EiEiajF yqk2h1vovbAGo8ZPM7lHzIURhPSd23pgwnXrwwHfKoryEqvjkJMRwT9Ya8G5EaHwutxo taC0MAH88Z5X/YoqYPfY8EUq4po7up90GRvSAr7NlB8xoDMgxQgFZkOrM5mETYJE6Ma9 +GFrxgK9xMn3Yp8t0DAUvwswCxtSEjisPhLj/xf3N0mMPzySnQlhnN6H9jb4LN6sbZAB B/KAJiU49C6YHPxkMa3cqXS7KkOKJ3ZyaVFGCzRLUXx1rNUzp8jPAAuRj5F2xM1o6ZsJ /xRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:date:cc:to:from:subject :message-id:arc-authentication-results; bh=i27y9BlgqUaNPw3zIPY2udFLDrdRxLKZvPQWSScHdOc=; b=JysVOKfAaY4xnDyER7OcqOChWMFoXLIk9q4yOsnpoD6CgMPNTaqTNylplv9owr8qF8 yTshsyBIq3G8Y8GL3SQN7TgrHkdMs1h07kKHGeekNhUHpEzAcVlu+EymXCI7uO6FKR5o VtkvMC5a1KV3NFNaih/Rs3ixRybyzJj+PNQiqMg0Or5PGE2866yUwUf9ylsMOsjzLnf6 K86Lb/1kFaTBNwWcLkVY6VZykXRhfKnfGGdhJQXsZRRUUDOsFByH3M9osBGB8l32jmQD 0EWnwMiJCN8cPqHI1cHaL0IXICxgrgsc9t8IwikJVSxKLmpw932PMeevos17fkDUk2bk yY0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c15si17806805pgt.208.2017.11.15.06.45.29; Wed, 15 Nov 2017 06:45:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758061AbdKOOnQ (ORCPT + 89 others); Wed, 15 Nov 2017 09:43:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55774 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757995AbdKOOnF (ORCPT ); Wed, 15 Nov 2017 09:43:05 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 59150C0587FC; Wed, 15 Nov 2017 14:43:05 +0000 (UTC) Received: from annuminas.surriel.com (ovpn-126-55.rdu2.redhat.com [10.10.126.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEC5B7D148; Wed, 15 Nov 2017 14:43:01 +0000 (UTC) Message-ID: <1510756981.21121.291.camel@redhat.com> Subject: Re: [PATCH 1/2] x86,kvm: move qemu/guest FPU switching out to vcpu_run From: Rik van Riel To: "quan.xu04@gmail.com" , pbonzini@redhat.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, david@redhat.com, borntraeger@de.ibm.com, tglx@linutronix.de, rkrcmar@redhat.com, Quan Xu Date: Wed, 15 Nov 2017 09:43:01 -0500 In-Reply-To: <2e83dd3f-8f03-03ac-45e0-f2fae1d17013@gmail.com> References: <20171114215424.32214-1-riel@redhat.com> <20171114215424.32214-2-riel@redhat.com> <2e83dd3f-8f03-03ac-45e0-f2fae1d17013@gmail.com> Organization: Red Hat, Inc Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 15 Nov 2017 14:43:05 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2017-11-15 at 14:53 +0800, quan.xu04@gmail.com wrote: > > On 2017/11/15 05:54, riel@redhat.com wrote: > > From: Rik van Riel > > > > Currently, every time a VCPU is scheduled out, the host kernel will > > first save the guest FPU/xstate context, then load the qemu > > userspace > > FPU context, only to then immediately save the qemu userspace FPU > > context back to memory. When scheduling in a VCPU, the same > > extraneous > > FPU loads and saves are done. > > Rik, be careful with VM migration. with you patch, I don't think you  > could load fpu/xstate >    context accurately after VM migration. Can you explain why you believe that? Getting the guest FPU or XSTATE is done under the vcpu->mutex. This patch switches out guest and userspace FPU/XSTATE under the vcpu->mutex, and switches it back before releasing the vcpu->mutex. By the time a KVM_GET_FPU has obtained the vcpu->mutex, the guest FPU state will be in vcpu->arch.guest_fpu.state, where you expect it to be. What am I missing? From 1584143475626487432@xxx Wed Nov 15 14:42:26 +0000 2017 X-GM-THRID: 1584017174910331026 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread