Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1123204ybg; Thu, 11 Jun 2020 01:18:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDxBCeg3X+RGS1BMeXzt9eoHZ8wCF0aKZNj2uU2S0gJ5wjzIzaSTdsMXE4mAHeCogG7jfY X-Received: by 2002:a17:907:1104:: with SMTP id qu4mr6294977ejb.382.1591863515181; Thu, 11 Jun 2020 01:18:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591863515; cv=none; d=google.com; s=arc-20160816; b=txn6qzjNUtzJD1C4cbWZOIn515+cK+IP8Ye4nvtzbza1QFbmixrk5q+ejSlyMIkDqq qhvmlNvUTSypigD6zfjrbOGvRsizWRrW7squXm84+0pxjWdIRwko4M2+bo2oV6vqBABY GP9ZyHHdCY94ejZBnhDVuYW9/qZbueXpkxCLaePVA1fxjAjwQ9KOCH5q5bIGa7h3CxDi uoN0NOl1PF+3PRX+K5pgq/0jdxj+wn61LV4Srg48e3WN5H/dDEDl93EX1PZKFBSllqZ9 vFjD+zP/h9Ssja4FWbLeE/eUlucH9B8ZHecf0PjSWsAWLyVfWr3flzDjO37wlDm429/D IG1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=6d2EQPOsqa1ar4oQ2p7/Glt6a8pVE2+UZ79AyKGYcCI=; b=v1CNQzJ7msVhj+sYBptOsvZteOTS3PLNVHGo4/qnl41wEcVf8o5DFRBbtOv/h0tEJ7 hpHugI+BYgU7UJbuN1XJbF6Vurw5seutWeK8NWh/86K6ENm3nItwmNdmpSPHxVA+XY6T tE5she/eCElHTpY7AV1/YzsfDzTNYwY/msHUvipgbeii8vA2tsZYQudrG8jwVAB91Xrr Q1LZo6f1XECtDj6MN75sEVWCcvihNCWju90GEfDgbWl4od045i04yVoeFe5yCyS9xTiS 07N8Uoowwomw+lSIu+VWxSpia02dI03OInGARxUzWeB8EHf0lnnvyqu868ZG/L0gffNJ O+3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=G4JIXey8; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lr6si1583171ejb.699.2020.06.11.01.18.12; Thu, 11 Jun 2020 01:18:35 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=G4JIXey8; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726620AbgFKIOT (ORCPT + 99 others); Thu, 11 Jun 2020 04:14:19 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:54886 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726623AbgFKIOS (ORCPT ); Thu, 11 Jun 2020 04:14:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591863256; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6d2EQPOsqa1ar4oQ2p7/Glt6a8pVE2+UZ79AyKGYcCI=; b=G4JIXey8Hqf8vXC9ypEJJN3zPJi8gs5APXEdRKQoRF6qicUV724w6GvnnZ01rJ8t0lJ1+N gXX9kYj3TqKvKnMQrAVLfOEVoBMmvtbTCCHlKXPG0tnqdOQhjKTBund767iHy4oW8f1ot/ ELuitS1CNmEbk+BPZ4NPhi/9EHeGW4E= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-168-qOEE8kzOP_qW1F_BzXAM3g-1; Thu, 11 Jun 2020 04:14:15 -0400 X-MC-Unique: qOEE8kzOP_qW1F_BzXAM3g-1 Received: by mail-ed1-f69.google.com with SMTP id y5so1407432edw.19 for ; Thu, 11 Jun 2020 01:14:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=6d2EQPOsqa1ar4oQ2p7/Glt6a8pVE2+UZ79AyKGYcCI=; b=peqL2irpIrkOzmpoq7pXA11ACOXIvN3+oK0xNWQoUKE+69CNwyOSxnxqOvbpfto5zE rbPAVatkSPRZqjsDVE90W1ZLg7cisRbSu4hujxgGOcZZj2ZAVNccgUPT2DMLo9ZYmpb+ 2MSwViAWiNQcV1WPwu09CpOp89wBigj33r5Iw9aiuM+53A5iAPk+saZDjfReUaPngOS/ 1UVCgcky9MM3C/Fo8j1tH+BM/3RW4g7onOL3ynhuj4fkkBjN5HRa1s5WYKgBmcFmkVUe YOqhQETJMmNXxMW58O3CoYcAsZi3v96TU+uARBa1yVhUPZaKZU8UvSInRwEDCvmkPMyV q20g== X-Gm-Message-State: AOAM530Hlo87ufxkja2LLe6T8NqXisGSva+KKl7TXnQv1nMxsijfNX6G hfbmJhjxluoumfR9yK+ugDxh6TXNRoUMi3sQpTbrXJaKgt8ywY+kMSEEkjSDLF1yTUMflwbTuh/ 1tvgBEXorWNW08MAtKRt5hefm X-Received: by 2002:a05:6402:1bdc:: with SMTP id ch28mr5781446edb.19.1591863253571; Thu, 11 Jun 2020 01:14:13 -0700 (PDT) X-Received: by 2002:a05:6402:1bdc:: with SMTP id ch28mr5781428edb.19.1591863253290; Thu, 11 Jun 2020 01:14:13 -0700 (PDT) Received: from vitty.brq.redhat.com (g-server-2.ign.cz. [91.219.240.2]) by smtp.gmail.com with ESMTPSA id u13sm1452034ejf.60.2020.06.11.01.14.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jun 2020 01:14:12 -0700 (PDT) From: Vitaly Kuznetsov To: Vivek Goyal Cc: kvm@vger.kernel.org, Paolo Bonzini , Sean Christopherson , 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 In-Reply-To: <20200610193211.GB243520@redhat.com> References: <20200610175532.779793-1-vkuznets@redhat.com> <20200610175532.779793-2-vkuznets@redhat.com> <20200610193211.GB243520@redhat.com> Date: Thu, 11 Jun 2020 10:14:11 +0200 Message-ID: <87v9jy9fzg.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Vivek Goyal writes: > 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. > I think it's the 'kvm_arch_async_page_not_present' name which is a bit misleading now, if we rename it to something like kvm_arch_inject_apf_not_present() then it becomes a bit more clear what's going on. We may as well write the code as if (kvm_arch_inject_apf_not_present()) work->notpresent_injected = true; or change the return type to int so it'll be if (!kvm_arch_inject_apf_not_present()) work->notpresent_injected = true; > 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. Thank you for testing! -- Vitaly