From patchwork Fri Feb 17 15:23:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= X-Patchwork-Id: 9580135 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B52D6600F6 for ; Fri, 17 Feb 2017 15:24:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A669C286FE for ; Fri, 17 Feb 2017 15:24:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9AA7228710; Fri, 17 Feb 2017 15:24:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,HK_RANDOM_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31CC52870C for ; Fri, 17 Feb 2017 15:24:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934229AbdBQPYC (ORCPT ); Fri, 17 Feb 2017 10:24:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46616 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934066AbdBQPYB (ORCPT ); Fri, 17 Feb 2017 10:24:01 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C7A1461B97; Fri, 17 Feb 2017 15:24:01 +0000 (UTC) Received: from potion (dhcp-1-208.brq.redhat.com [10.34.1.208]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id v1HFNw7O017670; Fri, 17 Feb 2017 10:23:59 -0500 Received: by potion (sSMTP sendmail emulation); Fri, 17 Feb 2017 16:23:57 +0100 Date: Fri, 17 Feb 2017 16:23:57 +0100 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Christian Borntraeger Cc: Paolo Bonzini , KVM , Cornelia Huck , linux-s390 , David Hildenbrand Subject: Re: [PATCH/RFC 2/2] KVM: enable kvm_vcpu_kick/wake_up for s390 Message-ID: <20170217152357.GF12224@potion> References: <1487337007-91063-1-git-send-email-borntraeger@de.ibm.com> <1487337007-91063-3-git-send-email-borntraeger@de.ibm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1487337007-91063-3-git-send-email-borntraeger@de.ibm.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 17 Feb 2017 15:24:01 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 2017-02-17 14:10+0100, Christian Borntraeger: > while we still need to provide our private version of kick and wakeup > to synchronize with some special cases, we can still enable the common > code variant. > > Signed-off-by: Christian Borntraeger > --- > arch/s390/kvm/kvm-s390.c | 12 ++++++++++-- > virt/kvm/kvm_main.c | 2 -- > 2 files changed, 10 insertions(+), 4 deletions(-) > > diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c > index 7cfd0dd..fa20686 100644 > --- a/arch/s390/kvm/kvm-s390.c > +++ b/arch/s390/kvm/kvm-s390.c > @@ -2485,8 +2485,14 @@ static void kvm_gmap_notifier(struct gmap *gmap, unsigned long start, > > int kvm_arch_vcpu_should_kick(struct kvm_vcpu *vcpu) > { > - /* kvm common code refers to this, but never calls it */ > - BUG(); > + /* > + * STOP indication is resetted when delivering interrupts. This > + * is done before we handle requests, so we only "loose" this > + * when we are still going to handle requests. In that case > + * we no longer need that STOP indication. > + */ > + __set_cpuflag(vcpu, CPUSTAT_STOP_INT); > + kvm_s390_vsie_kick(vcpu); I wouldn't put the kick into that function. On other architectures, the function decides whether we should call an operation that actually forces the exit. e.g. x86 and arm do return kvm_vcpu_exiting_guest_mode(vcpu) == IN_GUEST_MODE (which also contains an optimization, because they will not kick a VCPU twice or do a kick for a VCPU outside the guest mode.) There little point in having vcpu->mode if we do not use it here. And we'd also like to use kvm_arch_vcpu_should_kick() for the same decision in kvm_make_all_cpus_request(); basic idea: diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 4f4d250e1f53..676c0636d73c 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -163,10 +163,6 @@ void vcpu_put(struct kvm_vcpu *vcpu) } EXPORT_SYMBOL_GPL(vcpu_put); -static void ack_flush(void *_completed) -{ -} - bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req) { int i, cpu, me; @@ -194,13 +190,13 @@ bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req) smp_mb__after_atomic(); if (cpus != NULL && cpu != -1 && cpu != me && - kvm_vcpu_exiting_guest_mode(vcpu) != OUTSIDE_GUEST_MODE) + kvm_arch_vcpu_should_kick(vcpu)) cpumask_set_cpu(cpu, cpus); } if (unlikely(cpus == NULL)) - smp_call_function_many(cpu_online_mask, ack_flush, NULL, 1); + kvm_arch_cpu_kick_many(cpu_online_mask); else if (!cpumask_empty(cpus)) - smp_call_function_many(cpus, ack_flush, NULL, 1); + kvm_arch_cpu_kick_many(cpus); else called = false; put_cpu();