Hugetlb live update support does not yet work with CMA. Print a warning
and disable CMA if the config for live updating hugetlb is enabled, and
liveupdate is enabled at runtime.
Signed-off-by: Pratyush Yadav <pratyush@kernel.org>
---
kernel/liveupdate/Kconfig | 3 +++
mm/hugetlb_cma.c | 7 +++++++
2 files changed, 10 insertions(+)
diff --git a/kernel/liveupdate/Kconfig b/kernel/liveupdate/Kconfig
index 86e76aed8a93..4676fea6d8a6 100644
--- a/kernel/liveupdate/Kconfig
+++ b/kernel/liveupdate/Kconfig
@@ -82,6 +82,9 @@ config LIVEUPDATE_HUGETLB
use hugetlb memfd to back VM memory, or for other user workloads needing
to live update huge pages.
+ Enabling this config disables CMA for hugetlb pages. It is not yet
+ supported with live update.
+
If unsure, say N.
endmenu
diff --git a/mm/hugetlb_cma.c b/mm/hugetlb_cma.c
index e8e4dc7182d5..fa3bb776c0d2 100644
--- a/mm/hugetlb_cma.c
+++ b/mm/hugetlb_cma.c
@@ -4,6 +4,7 @@
#include <linux/cma.h>
#include <linux/compiler.h>
#include <linux/mm_inline.h>
+#include <linux/liveupdate.h>
#include <asm/page.h>
#include <asm/setup.h>
@@ -152,6 +153,12 @@ void __init hugetlb_cma_reserve(int order)
if (!hugetlb_cma_size)
return;
+ if (IS_ENABLED(CONFIG_LIVEUPDATE_HUGETLB) && liveupdate_enabled()) {
+ pr_warn("HugeTLB: CMA not supported with live update. Falling back to pre-allocating pages.\n");
+ hugetlb_cma_size = 0;
+ return;
+ }
+
hugetlb_bootmem_set_nodes();
for (nid = 0; nid < MAX_NUMNODES; nid++) {
--
2.43.0