Re: [PATCH RFC 5/5] mm/filemap: refuse releasing maybe_dma_pinned folios

From: Jan Kara

Date: Wed Nov 25 2026 - 03:52:42 EST


On Wed 25-11-26 09:47:39, Jan Kara wrote:
> On Thu 19-11-26 20:10:48, Pedro Falcato wrote:
> > Some callers, like folio_unmap_invalidate(), call filemap_release_folio()
> > without any care for folio refcounts. This is on purpose. As
> > folio_unmap_invalidate() states, invalidate_inode_pages2() needs stronger
> > guarantees, and "can't afford to leave folios behind because
> > shrink_folio_list() has a temp ref on them". Ok.
> >
> > Use folio_maybe_dma_pinned() universally, in filemap_release_folio(). This
> > has a much lower false positive rate, and should be ok enough for most
> > serious cases.
> >
> > While here, properly assert that no folio passed to release_folio is
> > mapped.
> >
> > Cc: stable@xxxxxxxxxxxxxxx
> > Fixes: d824ec2a1546 ("mm: do not reclaim private data from pinned page")
> > Signed-off-by: Pedro Falcato <pfalcato@xxxxxxx>
>
> Looks good to me. Feel free to add:
>
> Reviewed-by: Jan Kara <jack@xxxxxxx>
>
> and we'll see whether there's some path which actually required private
> data on pinned page to be freed in some cornercase :)

Oh, now I can see Sashiko already found some :).

Honza
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR