[PATCH] mm/huge_mm: define memcg_alloc_deferred() for !CONFIG_TRANSPARENT_HUGEPPAGE

From: SeongJae Park

Date: Thu May 28 2026 - 02:58:07 EST


Without this, UM mode kunit fails like below.

$ ./tools/testing/kunit/kunit.py run --kunitconfig mm/damon/tests/
[00:00:02] Configuring KUnit Kernel ...
[00:00:02] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make all compile_commands.json scripts_gdb ARCH=um O=.kunit --jobs=8
ERROR:root:../mm/swap_state.c: In function ‘__swap_cache_alloc’:
../mm/swap_state.c:468:26: error: implicit declaration of function ‘folio_memcg_alloc_deferred’ [-Wimplicit-function-declaration]
468 | if (order > 1 && folio_memcg_alloc_deferred(folio)) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
make[4]: *** [../scripts/Makefile.build:289: mm/swap_state.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [../scripts/Makefile.build:548: mm] Error 2
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [/home/lkhack/linux/Makefile:2143: .] Error 2
make[1]: *** [/home/lkhack/linux/Makefile:248: __sub-make] Error 2
make: *** [Makefile:248: __sub-make] Error 2

Fix by implementing the function for CONFIG_TRANSPARENT_HUGEPPAGE unset
case.

Fixes: https://lore.kernel.org/20260527204757.2544958-10-hannes@xxxxxxxxxxx
Signed-off-by: SeongJae Park <sj@xxxxxxxxxx>
---
include/linux/huge_mm.h | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
index f6c2531a27a35..055de7b8ed487 100644
--- a/include/linux/huge_mm.h
+++ b/include/linux/huge_mm.h
@@ -663,6 +663,11 @@ static inline int folio_split(struct folio *folio, unsigned int new_order,
return -EINVAL;
}

+static inline int folio_memcg_alloc_deferred(struct folio *folio)
+{
+ return 0;
+}
+
static inline void deferred_split_folio(struct folio *folio, bool partially_mapped) {}
#define split_huge_pmd(__vma, __pmd, __address) \
do { } while (0)
--
2.47.3