Re: [PATCH v1 14/26] mm: Add __free() support for folio_put()

Xu Yilun
2025-12-23T11:00:50Z

On Fri, Dec 19, 2025 at 11:55:07AM +0000, Jonathan Cameron wrote:
> On Mon, 17 Nov 2025 10:22:58 +0800
> Xu Yilun <yilun.xu@linux.intel.com> wrote:
>
> > Allow for the declaration of struct folio * variables that trigger
> > folio_put() when they go out of scope.
> >
> > Signed-off-by: Xu Yilun <yilun.xu@linux.intel.com>
> > ---
> > include/linux/mm.h | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/include/linux/mm.h b/include/linux/mm.h
> > index d16b33bacc32..2456bb775e27 100644
> > --- a/include/linux/mm.h
> > +++ b/include/linux/mm.h
> > @@ -1425,6 +1425,8 @@ static inline void folio_put(struct folio *folio)
> > __folio_put(folio);
> > }
> >
> > +DEFINE_FREE(folio_put, struct folio *, if (_T) folio_put(_T))
>
> Seems like a reasonable addition to me.
> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>

Sorry I'll also drop this one cause I'll drop __free() in tdx core.

>
> > +
> > /**
> > * folio_put_refs - Reduce the reference count on a folio.
> > * @folio: The folio.
>