Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp773347ybg; Wed, 10 Jun 2020 13:21:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwA9T8oKGK0au0hchVqiKcsyHO7lsOlSOne1fQjOGc4TbIXIGGvzHq9zx7MgVLpPz0VfZZ2 X-Received: by 2002:aa7:d952:: with SMTP id l18mr3965043eds.151.1591820469608; Wed, 10 Jun 2020 13:21:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591820469; cv=none; d=google.com; s=arc-20160816; b=JKogid4ITwC7neHUF2S1cfeD+3u+qylAtwVws8wM04Z3YsWn3EjXO/w3o6jetfxT2l DCRq/wcCGBqhhEpWAWS26h2FG6mupQT8i403XgbXURnPHdJwrxFUbhK3PwMIo4ofErV6 njzw756gYHdNyog/8ufVgdlH0spISrr7ny6b+DtP+PvBS+ky+oL0/9OF35a+mPW5hTxn +sf0aaf67zqpciANT/ww2QbPiFZ+fSRC40eChurHUFLGtdUOVrH7NmgePggzcR3dQrdz f9pXruAi7KVitBYUjEOHPGxMk8cwKoE29ifTdmlgDtUjQUbcAIglAHSSWrW1Hxa8jt/s ba2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=9UrOQfOu5vzpdSYgmxm3/50Q+B1OWbdzdrxofGEEQ+s=; b=rJa43O3Dz/GgE2eKx61ObYzQbGZmJMLV1djhQPGe6sjhD95a1N+Q+FEpnIxM4UErx/ 5Iz4v9kcHzQQldUshHHXhNEEgvEla7EIaVZl7TRDQzqnaUzYIO7sorGjzYSFPSf8eEf2 foH2f0qyRuuKVZ8z0t3cg0VXCN6kY3Xy2neB2QRFdv11DaALK5J78eSO9xew+Le5ykTA u/TSnX92p0COJOk4cQQ7DLQRV8APzt68BtCErlIQx9Xnz8TPdb09qrAG1p1f5FL/D1c2 FY+s9vh846Of9sKOcHIV+60pRGt5E6BSSL52Rxyyob1R/Lde+qe7dPK09UIinWrot8S8 2m/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gv10si656483ejb.578.2020.06.10.13.20.46; Wed, 10 Jun 2020 13:21:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730313AbgFJTrj (ORCPT + 99 others); Wed, 10 Jun 2020 15:47:39 -0400 Received: from mga02.intel.com ([134.134.136.20]:47507 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727038AbgFJTrj (ORCPT ); Wed, 10 Jun 2020 15:47:39 -0400 IronPort-SDR: y7yfGGrmlytIE06CqEttsoWJHGAATeU1svuJaDXogwv5D+PPIf6q+JM0xqXHEgxd9agdc6ZU/t IIAdZDzV1f1g== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2020 12:47:38 -0700 IronPort-SDR: zwsDaZkbBTj0lednQXl1zdUaM7MuxdMUT/XCO8fVZzLlLxwpQr2q5ueRRJ7kjHHo1OraSddyEs 5JivjUsJxnTg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,497,1583222400"; d="scan'208";a="306723019" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.152]) by fmsmga002.fm.intel.com with ESMTP; 10 Jun 2020 12:47:38 -0700 Date: Wed, 10 Jun 2020 12:47:38 -0700 From: Sean Christopherson To: Vivek Goyal Cc: Vitaly Kuznetsov , kvm@vger.kernel.org, Paolo Bonzini , Wanpeng Li , Jim Mattson , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] KVM: async_pf: Inject 'page ready' event only if 'page not present' was previously injected Message-ID: <20200610194738.GE18790@linux.intel.com> References: <20200610175532.779793-1-vkuznets@redhat.com> <20200610175532.779793-2-vkuznets@redhat.com> <20200610193211.GB243520@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200610193211.GB243520@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 10, 2020 at 03:32:11PM -0400, Vivek Goyal wrote: > On Wed, Jun 10, 2020 at 07:55:32PM +0200, Vitaly Kuznetsov wrote: > > 'Page not present' event may or may not get injected depending on > > guest's state. If the event wasn't injected, there is no need to > > inject the corresponding 'page ready' event as the guest may get > > confused. E.g. Linux thinks that the corresponding 'page not present' > > event wasn't delivered *yet* and allocates a 'dummy entry' for it. > > This entry is never freed. > > > > Note, 'wakeup all' events have no corresponding 'page not present' > > event and always get injected. > > > > s390 seems to always be able to inject 'page not present', the > > change is effectively a nop. > > > > Suggested-by: Vivek Goyal > > Signed-off-by: Vitaly Kuznetsov > > --- > > arch/s390/include/asm/kvm_host.h | 2 +- > > arch/s390/kvm/kvm-s390.c | 4 +++- > > arch/x86/include/asm/kvm_host.h | 2 +- > > arch/x86/kvm/x86.c | 7 +++++-- > > include/linux/kvm_host.h | 1 + > > virt/kvm/async_pf.c | 2 +- > > 6 files changed, 12 insertions(+), 6 deletions(-) > > > > diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h > > index 3d554887794e..cee3cb6455a2 100644 > > --- a/arch/s390/include/asm/kvm_host.h > > +++ b/arch/s390/include/asm/kvm_host.h > > @@ -978,7 +978,7 @@ bool kvm_arch_can_dequeue_async_page_present(struct kvm_vcpu *vcpu); > > void kvm_arch_async_page_ready(struct kvm_vcpu *vcpu, > > struct kvm_async_pf *work); > > > > -void kvm_arch_async_page_not_present(struct kvm_vcpu *vcpu, > > +bool kvm_arch_async_page_not_present(struct kvm_vcpu *vcpu, > > struct kvm_async_pf *work); > > Hi Vitaly, > > A minor nit. Using return code to figure out if exception was injected > or not is little odd. How about we pass a pointer instead as parameter > and kvm_arch_async_page_not_present() sets it to true if page not > present exception was injected. This probably will be easier to > read. > > If for some reason you don't like above, atleats it warrants a comment > explaining what do 0 and 1 mean. > > Otherwise both the patches look good to me. I tested and I can confirm > that now page ready events are not being delivered to guest if page > not present was not injected. Why does kvm_arch_async_page_not_present() need to "return" anything? It has access to @work, e.g. simply replace "return true" with "work->notpresent_injected = true".