On Fri, Sep 12, 2025 at 09:17:31AM +0000, Roy, Patrick wrote:
> From: Elliot Berman <[email protected]>
> 
> When guest_memfd removes memory from the host kernel's direct map,
> direct map entries must be restored before the memory is freed again. To
> do so, ->free_folio() needs to know whether a gmem folio was direct map
> removed in the first place though. While possible to keep track of this
> information on each individual folio (e.g. via page flags), direct map
> removal is an all-or-nothing property of the entire guest_memfd, so it
> is less error prone to just check the flag stored in the gmem inode's
> private data.  However, by the time ->free_folio() is called,
> folio->mapping might be cleared. To still allow access to the address
> space from which the folio was just removed, pass it in as an additional
> argument to ->free_folio, as the mapping is well-known to all callers.
> 
> Link: 
> https://lore.kernel.org/all/[email protected]/
> Suggested-by: David Hildenbrand <[email protected]>
> Acked-by: David Hildenbrand <[email protected]>
> Signed-off-by: Elliot Berman <[email protected]>
> [patrick: rewrite shortlog for new usecase]
> Signed-off-by: Patrick Roy <[email protected]>

Reviewed-by: Pedro Falcato <[email protected]>

-- 
Pedro

Reply via email to