From 2b4910e9d6cd5fc6dc54305a79a3c6cb451572e7 Mon Sep 17 00:00:00 2001
From: Liu Shixin <liushixin2@huawei.com>
Date: Tue, 22 Mar 2022 17:28:27 +0800
Subject: [PATCH] mm/dynamic_hugetlb: only compile PG_pool on X86_64 and ARM64

hulk inclusion
category: bugfix
bugzilla: 46904, https://gitee.com/openeuler/kernel/issues/I4YXOA

--------------------------------

When building with defconfig on arm32, we got a compile error:
./include/linux/page-flags-layout.h:95:2: error: #error "Not enough bits in page flags"
   95 | #error "Not enough bits in page flags"
      |  ^~~~~

Limit PG_pool to compile only on X86_64 and ARM64 to resolve this issue.

Signed-off-by: Liu Shixin <liushixin2@huawei.com>
Reviewed-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com>
---
 fs/proc/page.c                 |  2 ++
 include/linux/page-flags.h     |  6 ++++++
 include/trace/events/mmflags.h | 10 ++++++++--
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/fs/proc/page.c b/fs/proc/page.c
index d00c23d543fe..4c5bef99ec10 100644
--- a/fs/proc/page.c
+++ b/fs/proc/page.c
@@ -220,7 +220,9 @@ u64 stable_page_flags(struct page *page)
 #ifdef CONFIG_64BIT
 	u |= kpf_copy_bit(k, KPF_ARCH_2,	PG_arch_2);
 #endif
+#if defined(CONFIG_X86_64) || defined(CONFIG_ARM64)
 	u |= kpf_copy_bit(k, KPF_POOL,		PG_pool);
+#endif
 
 	return u;
 };
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index eb2fe22bc0e9..e1af0a6c8165 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -139,7 +139,9 @@ enum pageflags {
 #ifdef CONFIG_64BIT
 	PG_arch_2,
 #endif
+#if defined(CONFIG_X86_64) || defined(CONFIG_ARM64)
 	PG_pool,		/* Used to track page allocated from dynamic hugetlb pool */
+#endif
 #ifdef CONFIG_PIN_MEMORY
 	PG_hotreplace,
 #endif
@@ -474,7 +476,11 @@ __PAGEFLAG(Reported, reported, PF_NO_COMPOUND)
 /*
  * PagePool() is used to track page allocated from hpool.
  */
+#if defined(CONFIG_X86_64) || defined(CONFIG_ARM64)
 PAGEFLAG(Pool, pool, PF_NO_TAIL)
+#else
+PAGEFLAG_FALSE(Pool)
+#endif
 
 /*
  * On an anonymous page mapped into a user virtual memory area,
diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h
index dc1805fbf893..b50012bea1ef 100644
--- a/include/trace/events/mmflags.h
+++ b/include/trace/events/mmflags.h
@@ -87,6 +87,12 @@
 #define IF_HAVE_PG_ARCH_2(flag,string)
 #endif
 
+#if defined(CONFIG_X86_64) || defined(CONFIG_ARM64)
+#define IF_HAVE_PG_POOL(flag,string) ,{1UL << flag, string}
+#else
+#define IF_HAVE_PG_POOL(flag,string)
+#endif
+
 #ifdef CONFIG_PIN_MEMORY
 #define IF_HAVE_PG_HOTREPLACE(flag, string) ,{1UL << flag, string}
 #else
@@ -114,14 +120,14 @@
 	{1UL << PG_mappedtodisk,	"mappedtodisk"	},		\
 	{1UL << PG_reclaim,		"reclaim"	},		\
 	{1UL << PG_swapbacked,		"swapbacked"	},		\
-	{1UL << PG_unevictable,		"unevictable"	},		\
-	{1UL << PG_pool,		"pool"		}		\
+	{1UL << PG_unevictable,		"unevictable"	}		\
 IF_HAVE_PG_MLOCK(PG_mlocked,		"mlocked"	)		\
 IF_HAVE_PG_UNCACHED(PG_uncached,	"uncached"	)		\
 IF_HAVE_PG_HWPOISON(PG_hwpoison,	"hwpoison"	)		\
 IF_HAVE_PG_IDLE(PG_young,		"young"		)		\
 IF_HAVE_PG_IDLE(PG_idle,		"idle"		)		\
 IF_HAVE_PG_ARCH_2(PG_arch_2,		"arch_2"	)		\
+IF_HAVE_PG_POOL(PG_pool,		"pool"		)		\
 IF_HAVE_PG_HOTREPLACE(PG_hotreplace,	"hotreplace"	),		\
 	{1UL << PG_reserve_pgflag_0,	"reserve_pgflag_0"},		\
 	{1UL << PG_reserve_pgflag_1,	"reserve_pgflag_1"}
-- 
GitLab