Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755231AbcDFMgk (ORCPT ); Wed, 6 Apr 2016 08:36:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39431 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754965AbcDFMgj (ORCPT ); Wed, 6 Apr 2016 08:36:39 -0400 Date: Wed, 6 Apr 2016 14:36:27 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Suravee Suthikulpanit Cc: pbonzini@redhat.com, joro@8bytes.org, bp@alien8.de, gleb@kernel.org, alex.williamson@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, wei@redhat.com, sherry.hurwitz@amd.com Subject: Re: [PART1 RFC v3 12/12] svm: Manage vcpu load/unload when enable AVIC Message-ID: <20160406123627.GB17400@potion.brq.redhat.com> References: <1458281388-14452-1-git-send-email-Suravee.Suthikulpanit@amd.com> <1458281388-14452-13-git-send-email-Suravee.Suthikulpanit@amd.com> <20160318214450.GB2332@potion.brq.redhat.com> <56FCE556.80306@amd.com> <20160331141908.GA2171@potion.brq.redhat.com> <57038E6B.3080808@amd.com> <20160405145656.GA17400@potion.brq.redhat.com> <57048521.80509@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <57048521.80509@amd.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 06 Apr 2016 12:36:32 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 964 Lines: 28 2016-04-06 10:40+0700, Suravee Suthikulpanit: > On 04/05/2016 09:56 PM, Radim Krčmář wrote: >>I meant to change the place where we remember that is_running must not >>be true. Something like >> >> svm_vcpu_blocking(struct kvm_vcpu *vcpu): >> vcpu->is_blocking = true; >> avic_set_running(vcpu, false); >> >> avic_vcpu_load(struct kvm_vcpu *vcpu, bool is_load): >> avic_set_running(vcpu, is_load && !vcpu->is_blocking) > > I assume that you also imply that we would also need: > > svm_vcpu_unblocking(struct kvm_vcpu *vcpu) { > avic_set_running(vcpu, false); > vcpu->is_blocking = false; > } Yes, thought the order should be flipped in order to avoid suboptimal case when preemption hits us after avic_set_running(). static void svm_vcpu_unblocking(struct kvm_vcpu *vcpu) { vcpu->is_blocking = false; avic_set_running(vcpu, true); } avic_set_running has barriers that prevent GCC from harmful reordering.