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

Xu Yilun
2025-11-17T02:38:45Z

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))
+
/**
* folio_put_refs - Reduce the reference count on a folio.
* @folio: The folio.
--
2.25.1