Re: [PATCH] mm: memfd_luo: account restored large folios correctly

Pratyush Yadav
2026-04-14T10:48:38Z

Hi DaeMyung,

On Tue, Apr 14 2026, DaeMyung Kang wrote:

> memfd_luo_retrieve_folios() always passes 1 to
> shmem_inode_acct_blocks() and shmem_recalc_inode(), even when the
> restored folio spans multiple pages.
>
> That mismatches the normal shmem path: shmem_add_to_page_cache()
> accounts the folio in mapping->nrpages using folio_nr_pages(folio),
> and shmem_alloc_and_add_folio() passes the same page count to
> shmem_inode_acct_blocks() and shmem_recalc_inode().
>
> As a result, restored large folios are under-accounted in shmem inode
> and block accounting.
>
> Use folio_nr_pages(folio) here as well.
>
> Fixes: b3749f174d68 ("mm: memfd_luo: allow preserving memfd")
> Signed-off-by: DaeMyung Kang <charsyam@gmail.com>

Thanks for the patch. This bug is already fixed by this patch [0].

[0] https://lore.kernel.org/linux-mm/20260326084727.118437-2-duanchenghao@kylinos.cn/

[...]

--
Regards,
Pratyush Yadav