[PATCH] KVM: guest_memfd: Don't set FGP_ACCESSED when getting folios

Ackerley Tng posted 1 patch 1 week, 1 day ago
virt/kvm/guest_memfd.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
[PATCH] KVM: guest_memfd: Don't set FGP_ACCESSED when getting folios
Posted by Ackerley Tng 1 week, 1 day ago
guest_memfd folios don't care about accessed flags since the memory is
unevictable and there is no storage to write back to, hence, cleanup the
allocation path by not setting FGP_ACCESSED.

Signed-off-by: Ackerley Tng <ackerleytng@google.com>
[sean: split to separate patch]
Signed-off-by: Sean Christopherson <seanjc@google.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
---
 virt/kvm/guest_memfd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c
index fdaea3422c30..b3117f3359af 100644
--- a/virt/kvm/guest_memfd.c
+++ b/virt/kvm/guest_memfd.c
@@ -140,14 +140,13 @@ static struct folio *kvm_gmem_get_folio(struct inode *inode, pgoff_t index)
 	 * Fast-path: See if folio is already present in mapping to avoid
 	 * policy_lookup.
 	 */
-	folio = __filemap_get_folio(inode->i_mapping, index,
-				    FGP_LOCK | FGP_ACCESSED, 0);
+	folio = filemap_lock_folio(inode->i_mapping, index);
 	if (!IS_ERR(folio))
 		return folio;
 
 	policy = mpol_shared_policy_lookup(&GMEM_I(inode)->policy, index);
 	folio = __filemap_get_folio_mpol(inode->i_mapping, index,
-					 FGP_LOCK | FGP_ACCESSED | FGP_CREAT,
+					 FGP_LOCK | FGP_CREAT,
 					 mapping_gfp_mask(inode->i_mapping), policy);
 	mpol_cond_put(policy);
 
-- 
2.53.0.rc1.225.gd81095ad13-goog
Re: [PATCH] KVM: guest_memfd: Don't set FGP_ACCESSED when getting folios
Posted by David Hildenbrand (arm) 5 days, 1 hour ago
On 1/29/26 18:26, Ackerley Tng wrote:
> guest_memfd folios don't care about accessed flags since the memory is
> unevictable and there is no storage to write back to, hence, cleanup the
> allocation path by not setting FGP_ACCESSED.
> 
> Signed-off-by: Ackerley Tng <ackerleytng@google.com>
> [sean: split to separate patch]
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> Acked-by: Vlastimil Babka <vbabka@suse.cz>
> ---

Acked-by: David Hildenbrand (arm) <david@kernel.org>

-- 
Cheers

David