From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752405AbdKJKPS (ORCPT ); Fri, 10 Nov 2017 05:15:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41146 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751223AbdKJKPQ (ORCPT ); Fri, 10 Nov 2017 05:15:16 -0500 Subject: Re: [PATCH v3 4/4] KVM: Add flush_on_enter before guest enter To: Peter Zijlstra , Wanpeng Li Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Radim Kr??m???? , Wanpeng Li References: <1510307387-14812-1-git-send-email-wanpeng.li@hotmail.com> <1510307387-14812-5-git-send-email-wanpeng.li@hotmail.com> <20171110100838.eqfccs735x4ghw6q@hirez.programming.kicks-ass.net> From: Paolo Bonzini Message-ID: <58cda8a6-3bab-c34f-785b-dfff84eee69f@redhat.com> Date: Fri, 10 Nov 2017 11:15:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171110100838.eqfccs735x4ghw6q@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 10 Nov 2017 10:15:15 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/11/2017 11:08, Peter Zijlstra wrote: > On Fri, Nov 10, 2017 at 01:49:47AM -0800, Wanpeng Li wrote: >> @@ -2887,7 +2899,7 @@ static void kvm_steal_time_set_preempted(struct kvm_vcpu *vcpu) >> if (!(vcpu->arch.st.msr_val & KVM_MSR_ENABLED)) >> return; >> >> - vcpu->arch.st.steal.preempted = KVM_VCPU_PREEMPTED; >> + vcpu->arch.st.steal.preempted |= KVM_VCPU_PREEMPTED; > > I don't understand this one... If there is concurrency its wrong, if > there is no concurrency it still doesn't make sense as there should not > be any FLUSH flags to preserve.. There is no concurrency, foreign VCPUs are not going to write to the location unless PREEMPTED is set. So indeed the "|=" is pointless. However, I wonder if it'd be useful for a VCPU to set the bit _on itself_ before going to sleep. Like set KVM_VCPU_SHOULD_FLUSH hlt /* Automagic TLB flush! */ This would not work currently, but if it *is* useful, we should make it work and document it as legal. Peter, do you think it would make any sense? Thanks, Paolo >> >> kvm_write_guest_offset_cached(vcpu->kvm, &vcpu->arch.st.stime, >> &vcpu->arch.st.steal.preempted,