From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752626AbdGaRcv (ORCPT ); Mon, 31 Jul 2017 13:32:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40258 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752486AbdGaRcs (ORCPT ); Mon, 31 Jul 2017 13:32:48 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3C732FB9B4 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com Subject: Re: [RFC] KVM: optimize the kvm_vcpu_on_spin To: Christoffer Dall , "Longpeng(Mike)" 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 References: <1501309377-195256-1-git-send-email-longpeng2@huawei.com> <20170731132255.GZ5176@cbox> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: <8d64ea0f-4cd6-6b7d-8804-d29beeaef6e3@redhat.com> Date: Mon, 31 Jul 2017 19:32:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170731132255.GZ5176@cbox> 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.26]); Mon, 31 Jul 2017 17:32:48 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@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