[PATCH v5 1/2] filemap: Pass address_space mapping to ->free_folio()
Matthew Wilcox
willy at infradead.org
Fri Nov 22 10:22:54 PST 2024
On Fri, Nov 22, 2024 at 09:29:38AM -0800, Elliot Berman wrote:
> When guest_memfd becomes a library, a callback will need to be made to
> the owner (KVM SEV) to update the RMP entry for the page back to shared
> state. This is currently being done as part of .free_folio() operation,
> but this callback shouldn't assume that folio->mapping is set/valid.
I think this could be slightly clearer ...
guest_memfd wants to inform the owner of the page that the folio has
been removed from the mapping. The best place to do this is in the
free_folio() callback, but the folio's mapping pointer has already been
cleared. Pass the mapping in so that the callback knows which mapping
the folio has been removed from.
> ---
> Documentation/filesystems/locking.rst | 2 +-
Because life is hard, we also have documentation in vfs.rst. Can you
please update that one too?
> +++ b/virt/kvm/guest_memfd.c
> @@ -358,7 +358,8 @@ static int kvm_gmem_error_folio(struct address_space *mapping, struct folio *fol
> }
>
> #ifdef CONFIG_HAVE_KVM_ARCH_GMEM_INVALIDATE
> -static void kvm_gmem_free_folio(struct folio *folio)
> +static void kvm_gmem_free_folio(struct address_space *mapping,
> + struct folio *folio)
> {
> struct page *page = folio_page(folio, 0);
> kvm_pfn_t pfn = page_to_pfn(page);
You could just use folio_pfn() here; maybe sneak it in as part of this
patch or do a separate patch for it.
More information about the linux-arm-kernel
mailing list