[RFC PATCH v2 36/51] mm: Convert split_folio() macro to function

Ackerley Tng posted 51 patches 7 months, 1 week ago
[RFC PATCH v2 36/51] mm: Convert split_folio() macro to function
Posted by Ackerley Tng 7 months, 1 week ago
This will prevent the macro from overriding any function and function
calls defined as split_folio().

Change-Id: I88a66bd876731b272282a42468c3bf8ac008b7cc
Signed-off-by: Ackerley Tng <ackerleytng@google.com>
---
 include/linux/huge_mm.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
index e893d546a49f..f392ff49a816 100644
--- a/include/linux/huge_mm.h
+++ b/include/linux/huge_mm.h
@@ -99,7 +99,11 @@ extern struct kobj_attribute thpsize_shmem_enabled_attr;
 #define thp_vma_allowable_order(vma, vm_flags, tva_flags, order) \
 	(!!thp_vma_allowable_orders(vma, vm_flags, tva_flags, BIT(order)))
 
-#define split_folio(f) split_folio_to_list(f, NULL)
+int split_folio_to_list(struct folio *folio, struct list_head *list);
+static inline int split_folio(struct folio *folio)
+{
+	return split_folio_to_list(folio, NULL);
+}
 
 #ifdef CONFIG_PGTABLE_HAS_HUGE_LEAVES
 #define HPAGE_PMD_SHIFT PMD_SHIFT
-- 
2.49.0.1045.g170613ef41-goog
Re: [RFC PATCH v2 36/51] mm: Convert split_folio() macro to function
Posted by Edgecombe, Rick P 7 months ago
On Wed, 2025-05-14 at 16:42 -0700, Ackerley Tng wrote:
> +int split_folio_to_list(struct folio *folio, struct list_head *list);

With CONFIG_TRANSPARENT_HUGEPAGE=n, I get:

include/linux/huge_mm.h:569:19: error: static declaration of
‘split_folio_to_list’ follows non-static declaration
  569 | static inline int split_folio_to_list(struct folio *folio, struct
list_head *list)
      |                   ^~~~~~~~~~~~~~~~~~~
include/linux/huge_mm.h:102:5: note: previous declaration of
‘split_folio_to_list’ with type ‘int(struct folio *, struct list_head *)’
  102 | int split_folio_to_list(struct folio *folio, struct list_head *list);


> +static inline int split_folio(struct folio *folio)
> +{
> +	return split_folio_to_list(folio, NULL);
> +}
>