From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933200AbcGGLVc (ORCPT ); Thu, 7 Jul 2016 07:21:32 -0400 Received: from merlin.infradead.org ([205.233.59.134]:35832 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932829AbcGGLVa (ORCPT ); Thu, 7 Jul 2016 07:21:30 -0400 Date: Thu, 7 Jul 2016 13:21:21 +0200 From: Peter Zijlstra To: Wanpeng Li Cc: Paolo Bonzini , Pan Xinhui , linux-s390 , Davidlohr Bueso , mpe@ellerman.id.au, boqun.feng@gmail.com, will.deacon@arm.com, "linux-kernel@vger.kernel.org" , Waiman Long , virtualization@lists.linux-foundation.org, Ingo Molnar , Paul Mackerras , benh@kernel.crashing.org, schwidefsky@de.ibm.com, Paul McKenney , linuxppc-dev@lists.ozlabs.org, kvm Subject: Re: [PATCH v2 0/4] implement vcpu preempted check Message-ID: <20160707112121.GJ30927@twins.programming.kicks-ass.net> References: <1467124991-13164-1-git-send-email-xinhui.pan@linux.vnet.ibm.com> <20160706065255.GH30909@twins.programming.kicks-ass.net> <14a24854-9787-e4a1-c9a8-76eba4e97301@redhat.com> <8e8edf1b-b64b-3c44-b580-b9271663844c@redhat.com> <20160707094215.GT30921@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160707094215.GT30921@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 07, 2016 at 11:42:15AM +0200, Peter Zijlstra wrote: > +static void update_steal_time_preempt(struct kvm_vcpu *vcpu) > +{ > + struct kvm_steal_time *st; > + > + if (!(vcpu->arch.st.msr_val & KVM_MSR_ENABLED)) > + return; > + > + if (unlikely(kvm_read_guest_cached(vcpu->kvm, &vcpu->arch.st.stime, > + &vcpu->arch.st.steal, sizeof(struct kvm_steal_time)))) > + return; > + > + st = &vcpu->arch.st.steal; > + > + st->pad[KVM_ST_PAD_PREEMPT] = 1; /* we've stopped running */ So maybe have this be: ... = kvm_vcpu_running(); That avoids marking the vcpu preempted when we do hlt and such. > + kvm_write_guest_cached(vcpu->kvm, &vcpu->arch.st.stime, > + st, sizeof(struct kvm_steal_time)); > +} From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Zijlstra Subject: Re: [PATCH v2 0/4] implement vcpu preempted check Date: Thu, 7 Jul 2016 13:21:21 +0200 Message-ID: <20160707112121.GJ30927@twins.programming.kicks-ass.net> References: <1467124991-13164-1-git-send-email-xinhui.pan@linux.vnet.ibm.com> <20160706065255.GH30909@twins.programming.kicks-ass.net> <14a24854-9787-e4a1-c9a8-76eba4e97301@redhat.com> <8e8edf1b-b64b-3c44-b580-b9271663844c@redhat.com> <20160707094215.GT30921@twins.programming.kicks-ass.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: linux-s390 , Davidlohr Bueso , benh@kernel.crashing.org, kvm , mpe@ellerman.id.au, boqun.feng@gmail.com, will.deacon@arm.com, "linux-kernel@vger.kernel.org" , Waiman Long , virtualization@lists.linux-foundation.org, Ingo Molnar , Paul Mackerras , Pan Xinhui , schwidefsky@de.ibm.com, Paolo Bonzini , Paul McKenney , linuxppc-dev@lists.ozlabs.org To: Wanpeng Li Return-path: Content-Disposition: inline In-Reply-To: <20160707094215.GT30921@twins.programming.kicks-ass.net> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: virtualization-bounces@lists.linux-foundation.org Errors-To: virtualization-bounces@lists.linux-foundation.org List-Id: kvm.vger.kernel.org On Thu, Jul 07, 2016 at 11:42:15AM +0200, Peter Zijlstra wrote: > +static void update_steal_time_preempt(struct kvm_vcpu *vcpu) > +{ > + struct kvm_steal_time *st; > + > + if (!(vcpu->arch.st.msr_val & KVM_MSR_ENABLED)) > + return; > + > + if (unlikely(kvm_read_guest_cached(vcpu->kvm, &vcpu->arch.st.stime, > + &vcpu->arch.st.steal, sizeof(struct kvm_steal_time)))) > + return; > + > + st = &vcpu->arch.st.steal; > + > + st->pad[KVM_ST_PAD_PREEMPT] = 1; /* we've stopped running */ So maybe have this be: ... = kvm_vcpu_running(); That avoids marking the vcpu preempted when we do hlt and such. > + kvm_write_guest_cached(vcpu->kvm, &vcpu->arch.st.stime, > + st, sizeof(struct kvm_steal_time)); > +}