From nobody Wed Apr 8 17:33:29 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B857FECAAA1 for ; Thu, 27 Oct 2022 16:20:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236741AbiJ0QUB (ORCPT ); Thu, 27 Oct 2022 12:20:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236573AbiJ0QTB (ORCPT ); Thu, 27 Oct 2022 12:19:01 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C43A196085 for ; Thu, 27 Oct 2022 09:18:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666887536; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+cor0KkOwTJItYQfjwJp6M8Gzu8KNstW05/3cHmtpUg=; b=GujaRbwDPn39Xig8DrPWRTezKZjhDT+g1bNPrJ2me77U/AZj3+zlcCPOAf1Z8pCtrRNZEr dSL46XJjbHnSZPEkN416hlXxElYPRR9bnpONwGjdV2d8zYXi52uaMBmikSDkuHdugeAyHg k4fY/1sKkjfp6i5zMGrvQzEpJkXbLBQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-380-hzHo1hAyNE6NbZsqvCRP6Q-1; Thu, 27 Oct 2022 12:18:53 -0400 X-MC-Unique: hzHo1hAyNE6NbZsqvCRP6Q-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E30D2185A7A3; Thu, 27 Oct 2022 16:18:52 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id C223017593; Thu, 27 Oct 2022 16:18:52 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: mhal@rbox.co, seanjc@google.com Subject: [PATCH 14/16] KVM: Skip unnecessary "unmap" if gpc is already valid during refresh Date: Thu, 27 Oct 2022 12:18:47 -0400 Message-Id: <20221027161849.2989332-15-pbonzini@redhat.com> In-Reply-To: <20221027161849.2989332-1-pbonzini@redhat.com> References: <20221027161849.2989332-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Sean Christopherson When refreshing a gfn=3D>pfn cache, skip straight to unlocking if the cache already valid instead of stuffing the "old" variables to turn the unmapping outro into a nop. Signed-off-by: Sean Christopherson Message-Id: <20221013211234.1318131-15-seanjc@google.com> Signed-off-by: Paolo Bonzini --- virt/kvm/pfncache.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/virt/kvm/pfncache.c b/virt/kvm/pfncache.c index 68e2e53eac8a..b408a4b81e74 100644 --- a/virt/kvm/pfncache.c +++ b/virt/kvm/pfncache.c @@ -295,9 +295,8 @@ static int __kvm_gpc_refresh(struct gfn_to_pfn_cache *g= pc, gpa_t gpa, unsigned l ret =3D hva_to_pfn_retry(gpc); } else { /* If the HVA\ufffd\ufffd\ufffdPFN mapping was already valid, don't unma= p it. */ - old_pfn =3D KVM_PFN_ERR_FAULT; - old_khva =3D NULL; ret =3D 0; + goto out_unlock; } =20 out: --=20 2.31.1