From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4B5F3C3DA64 for ; Thu, 1 Aug 2024 09:21:53 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=p2d2Dwj0; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4WZNl36391z3dDT for ; Thu, 1 Aug 2024 19:21:51 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=p2d2Dwj0; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linaro.org (client-ip=2a00:1450:4864:20::534; helo=mail-ed1-x534.google.com; envelope-from=alex.bennee@linaro.org; receiver=lists.ozlabs.org) Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4WZNkD0R3cz2xdg for ; Thu, 1 Aug 2024 19:21:07 +1000 (AEST) Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-5a15692b6f6so10312750a12.0 for ; Thu, 01 Aug 2024 02:21:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722504063; x=1723108863; darn=lists.ozlabs.org; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=GQVA9z2jkUPxM3dqZI0KDPVXgKoffaizeXmufcNkJbk=; b=p2d2Dwj09G9RdfxypcG3YvvuYMeEDwcnpmAbBos5zvsviyzYImuXDHXF6C1e5bY/vv 60vIuwFtcY6GqfII79JlLBQ1LroaK3zphp6RJExpkrif623kZlfirpOAYp2Ty/iYXW1q Ln9SU6VUBvwJmxBb73xHpcQNuJVsWCwy5LXNWwlMNBfEpxt4eHwtiXG+RbphIJT5agl/ +52OgO/dDby7lqjReN8nCAIwtTEO7hkFNdbg2V877m6Te4ffVDXvCgFfG6v7J+b++lYS PzZmWnsi8qhP425XfbHEMHoH0m1hfyLUBtdiCtQR2o8F3r5OSVvMCHjXrgyYwnk3o/rE QQcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722504063; x=1723108863; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GQVA9z2jkUPxM3dqZI0KDPVXgKoffaizeXmufcNkJbk=; b=mm9PhcL15DJwG+G1ZFXoFlafuEaBnDhpbZkfDekQDjhJVwhj0CmfFhWdL7llYPckOm cuxcGZTYSeL6OLvNOW2YAEYVuECsBHOmYCDFwRuzuYfAvm1OTwyQd+nNLDTfYOvzCg82 gtM5KxF+bd1E9X4WHnfi100oQFMWSLmclsjuwm1gDUdYE915LSHUie4+YAgQQ3dRdxTe 2nB9ARaqVAkbVFUGUgTxM6oK3Yl0XumhAX05eg7p57G5EO3AGN80fXkko0nXriY0Vsxn zbbSEaM9LIq6hc/7hacNSEuTlyi/5/V2GHxPKPm5ai5gd1SWsw52bubwpUwO1GEaR5/w xBVw== X-Forwarded-Encrypted: i=1; AJvYcCVVn2REyQu0AW8gzaT+xl6uOMpLbbbtxh0axR3Mxl3LxEePMR17c5qiujZDZuP2x9tUpIADTGVPLpuRtFgU9FwuexVpB4svKMBMXhdmGg== X-Gm-Message-State: AOJu0YwrmpEOjN0Ta2Efpe6lmiXxKxV24VEs9qWS3TUcoqBq8644pG8T ckaDNLotU5b9I/eCf6INUfAp9O7Xx7FetjQcXN4/LSQb77j41LXBNnJgO7TKk14= X-Google-Smtp-Source: AGHT+IG4an2mFFKr4wz3Z9DFgeOmmND21A8Rbh3YvwoLKrs/2dCx443xl5h3j8lRXM2FS1yhxPSg2w== X-Received: by 2002:a50:ee82:0:b0:5a3:3062:36d6 with SMTP id 4fb4d7f45d1cf-5b6fe72ddc6mr1090738a12.1.1722504062925; Thu, 01 Aug 2024 02:21:02 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5b017787967sm7857844a12.9.2024.08.01.02.21.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 02:21:01 -0700 (PDT) Received: from draig (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 51C785F80C; Thu, 1 Aug 2024 10:20:59 +0100 (BST) From: =?utf-8?Q?Alex_Benn=C3=A9e?= To: Sean Christopherson Subject: Re: [PATCH v12 05/84] KVM: Add kvm_release_page_unused() API to put pages that KVM never consumes In-Reply-To: <20240726235234.228822-6-seanjc@google.com> (Sean Christopherson's message of "Fri, 26 Jul 2024 16:51:14 -0700") References: <20240726235234.228822-1-seanjc@google.com> <20240726235234.228822-6-seanjc@google.com> Date: Thu, 01 Aug 2024 10:20:59 +0100 Message-ID: <87wml0egzo.fsf@draig.linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, David Matlack , linux-riscv@lists.infradead.org, Claudio Imbrenda , Janosch Frank , Marc Zyngier , Huacai Chen , Christian Borntraeger , Albert Ou , Bibo Mao , loongarch@lists.linux.dev, Paul Walmsley , kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, Oliver Upton , Palmer Dabbelt , David Stevens , kvm-riscv@lists.infradead.org, Anup Patel , Paolo Bonzini , Tianrui Zhao , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Sean Christopherson writes: > Add an API to release an unused page, i.e. to put a page without marking > it accessed or dirty. The API will be used when KVM faults-in a page but > bails before installing the guest mapping (and other similar flows). > > Signed-off-by: Sean Christopherson > --- > include/linux/kvm_host.h | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > index 3d9617d1de41..c5d39a337aa3 100644 > --- a/include/linux/kvm_host.h > +++ b/include/linux/kvm_host.h > @@ -1201,6 +1201,15 @@ unsigned long gfn_to_hva_prot(struct kvm *kvm, gfn= _t gfn, bool *writable); > unsigned long gfn_to_hva_memslot(struct kvm_memory_slot *slot, gfn_t gfn= ); > unsigned long gfn_to_hva_memslot_prot(struct kvm_memory_slot *slot, gfn_= t gfn, > bool *writable); > + > +static inline void kvm_release_page_unused(struct page *page) > +{ > + if (!page) > + return; > + > + put_page(page); > +} I guess it's unfamiliarity with the mm layout but I was trying to find where the get_pages come from to see the full pattern of allocate and return. I guess somewhere in the depths of hva_to_pfn() from hva_to_pfn_retry()? I think the indirection of the page walking confuses me ;-) Anyway the API seems reasonable enough given the other kvm_release_ functions. Reviewed-by: Alex Benn=C3=A9e --=20 Alex Benn=C3=A9e Virtualisation Tech Lead @ Linaro