From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Hildenbrand Subject: Re: [RFC] KVM: optimize the kvm_vcpu_on_spin Date: Mon, 31 Jul 2017 19:32:26 +0200 Message-ID: <8d64ea0f-4cd6-6b7d-8804-d29beeaef6e3@redhat.com> References: <1501309377-195256-1-git-send-email-longpeng2@huawei.com> <20170731132255.GZ5176@cbox> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: pbonzini@redhat.com, rkrcmar@redhat.com, agraf@suse.com, borntraeger@de.ibm.com, cohuck@redhat.com, christoffer.dall@linaro.org, marc.zyngier@arm.com, james.hogan@imgtec.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, weidong.huang@huawei.com, arei.gonglei@huawei.com, wangxinxin.wang@huawei.com, longpeng.mike@gmail.com To: Christoffer Dall , "Longpeng(Mike)" Return-path: In-Reply-To: <20170731132255.GZ5176@cbox> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 31.07.2017 15:22, Christoffer Dall wrote: > On Sat, Jul 29, 2017 at 02:22:57PM +0800, Longpeng(Mike) wrote: >> We had disscuss the idea here: >> https://www.spinics.net/lists/kvm/msg140593.html > > This is not a very nice way to start a commit description. > > Please provide the necessary background to understand your change > directly in the commit message. > >> >> I think it's also suitable for other architectures. >> > > I think this sentence can go in the end of the commit message together > with your explanation of only doing this for x86. > > By the way, the ARM solution should be pretty simple: > > diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c > index a39a1e1..b9f68e4 100644 > --- a/virt/kvm/arm/arm.c > +++ b/virt/kvm/arm/arm.c > @@ -416,6 +416,11 @@ int kvm_arch_vcpu_runnable(struct kvm_vcpu *v) > && !v->arch.power_off && !v->arch.pause); > } > > +bool kvm_arch_vcpu_in_kernel(struct kvm_vcpu *vcpu) > +{ > + return vcpu_mode_priv(vcpu); > +} > + > /* Just ensure a guest exit from a particular CPU */ > static void exit_vm_noop(void *info) > { > > This one should work for s390x, no caching (or special access patterns like on x86) needed: +++ b/arch/s390/kvm/kvm-s390.c @@ -2447,6 +2447,11 @@ int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu) return kvm_s390_vcpu_has_irq(vcpu, 0); } +bool kvm_arch_vcpu_in_kernel(struct kvm_vcpu *vcpu) +{ + return !(vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE); +} + void kvm_s390_vcpu_block(struct kvm_vcpu *vcpu) { atomic_or(PROG_BLOCK_SIE, &vcpu->arch.sie_block->prog20); -- Thanks, David