Skip to contentSkip to conversation

KVM: guest_memfd: Don't set FGP_ACCESSED when getting folios

PATCH Applied Ackerley Tng 3 participants 3 messages Jan 29 – Mar 5

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: guest_memfd: Don't set FGP_ACCESSED when getting folios

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.

---
 virt/kvm/guest_memfd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
virt/kvm/guest_memfd.c +2 -3
index fdaea3422c30..b3117f3359af 100644
@@ -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);
 
Signature · 1 line
2.53.0.rc1.225.gd81095ad13-goog
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Ackerley Tng

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.

---

Signature · 3 lines
Cheers

David
maintainer Applied
#2 lore raw
In reply to Ackerley Tng
Quoted 3 lines · Ackerley Tng

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.

Applied to kvm-x86 gmem, thanks!

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

      https://github.com/kvm-x86/linux/commit/6dad5447c7bf

--
https://github.com/kvm-x86/linux/tree/next