Skip to contentSkip to conversation

arm64/hugetlb: Reserve CMA areas for gigantic pages on 16K and 64K configs

PATCH Superseded Anshuman Khandual 3 participants 4 messages Jun 29, 2020 – Jul 2, 2020

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 arm64/hugetlb: Reserve CMA areas for gigantic pages on 16K and 64K configs

Currently 'hugetlb_cma=' command line argument does not create CMA area on ARM64_16K_PAGES and ARM64_64K_PAGES based platforms. Instead, it just ends up with the following warning message. Reason being, hugetlb_cma_reserve() never gets called for these huge page sizes.

[   64.255669] hugetlb_cma: the option isn't supported by current arch

This enables CMA areas reservation on ARM64_16K_PAGES and ARM64_64K_PAGES configs by defining an unified arm64_hugetlb_cma_reseve() that is wrapped in CONFIG_CMA.

Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Mike Kravetz <[email protected]>
Cc Barry Song <[email protected]>
Cc Andrew Morton <[email protected]>

---
Applies on 5.8-rc3.

Changes in V2:

- Moved arm64_hugetlb_cma_reserve() stub and declaration near call site

Changes in V1: (https://patchwork.kernel.org/patch/11619839/)

 arch/arm64/mm/hugetlbpage.c | 38 +++++++++++++++++++++++++++++++++++++
 arch/arm64/mm/init.c        | 12 +++++++++---
 2 files changed, 47 insertions(+), 3 deletions(-)
arch/arm64/mm/hugetlbpage.c +38 -0
index 0a52ce46f020..ea7fb48b8617 100644
@@ -19,6 +19,44 @@
 #include <asm/tlbflush.h>
 #include <asm/pgalloc.h>
 
+/*
+ * HugeTLB Support Matrix
+ *
+ * ---------------------------------------------------
+ * | Page Size | CONT PTE |  PMD  | CONT PMD |  PUD  |
+ * ---------------------------------------------------
+ * |     4K    |   64K    |   2M  |    32M   |   1G  |
+ * |    16K    |    2M    |  32M  |     1G   |       |
+ * |    64K    |    2M    | 512M  |    16G   |       |
+ * ---------------------------------------------------
+ */
+
+/*
+ * Reserve CMA areas for the largest supported gigantic
+ * huge page when requested. Any other smaller gigantic
+ * huge pages could still be served from those areas.
+ */
+#ifdef CONFIG_CMA
+void __init arm64_hugetlb_cma_reserve(void)
+{
+	int order;
+
+#ifdef CONFIG_ARM64_4K_PAGES
+	order = PUD_SHIFT - PAGE_SHIFT;
+#else
+	order = CONT_PMD_SHIFT + PMD_SHIFT - PAGE_SHIFT;
+#endif
+	/*
+	 * HugeTLB CMA reservation is required for gigantic
+	 * huge pages which could not be allocated via the
+	 * page allocator. Just warn if there is any change
+	 * breaking this assumption.
+	 */
+	WARN_ON(order <= MAX_ORDER);
+	hugetlb_cma_reserve(order);
+}
+#endif /* CONFIG_CMA */
+
 #ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION
 bool arch_hugetlb_migration_supported(struct hstate *h)
 {
arch/arm64/mm/init.c +9 -3
index 1e93cfc7c47a..8a260ef0cb94 100644
@@ -406,6 +406,14 @@ void __init arm64_memblock_init(void)
 	dma_contiguous_reserve(arm64_dma32_phys_limit);
 }
 
+#if defined(CONFIG_HUGETLB_PAGE) && defined(CONFIG_CMA)
+void arm64_hugetlb_cma_reserve(void);
+#else
+static inline void arm64_hugetlb_cma_reserve(void)
+{
+}
+#endif
+
 void __init bootmem_init(void)
 {
 	unsigned long min, max;
@@ -425,9 +433,7 @@ void __init bootmem_init(void)
 	 * initialize node_online_map that gets used in hugetlb_cma_reserve()
 	 * while allocating required CMA size across online nodes.
 	 */
-#ifdef CONFIG_ARM64_4K_PAGES
-	hugetlb_cma_reserve(PUD_SHIFT - PAGE_SHIFT);
-#endif
+	arm64_hugetlb_cma_reserve();
 
 	/*
 	 * Sparsemem tries to allocate bootmem in memory_present(), so must be
Signature · 1 line
2.20.1
#1 lore raw
Thank you for the patch! Perhaps something to improve:

Hi Anshuman,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on v5.8-rc3]
[also build test WARNING on next-20200629]
[cannot apply to arm64/for-next/core]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Anshuman-Khandual/arm64-hugetlb-Reserve-CMA-areas-for-gigantic-pages-on-16K-and-64K-configs/20200629-144736
base:    9ebcfadb0610322ac537dd7aa5d9cbc2b2894c68
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm64

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

>> arch/arm64/mm/hugetlbpage.c:40:13: warning: no previous prototype for 'arm64_hugetlb_cma_reserve' [-Wmissing-prototypes]

40 | void __init arm64_hugetlb_cma_reserve(void)
| ^~~~~~~~~~~~~~~~~~~~~~~~~

vim +/arm64_hugetlb_cma_reserve +40 arch/arm64/mm/hugetlbpage.c

    21	
    22	/*
    23	 * HugeTLB Support Matrix
    24	 *
    25	 * ---------------------------------------------------
    26	 * | Page Size | CONT PTE |  PMD  | CONT PMD |  PUD  |
    27	 * ---------------------------------------------------
    28	 * |     4K    |   64K    |   2M  |    32M   |   1G  |
    29	 * |    16K    |    2M    |  32M  |     1G   |       |
    30	 * |    64K    |    2M    | 512M  |    16G   |       |
    31	 * ---------------------------------------------------
    32	 */
    33	
    34	/*
    35	 * Reserve CMA areas for the largest supported gigantic
    36	 * huge page when requested. Any other smaller gigantic
    37	 * huge pages could still be served from those areas.
    38	 */
    39	#ifdef CONFIG_CMA
  > 40	void __init arm64_hugetlb_cma_reserve(void)
    41	{
    42		int order;
    43	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#2 lore raw
Quoted 21 lines · kernel test robot

Hi Anshuman,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on v5.8-rc3]
[also build test WARNING on next-20200629]
[cannot apply to arm64/for-next/core]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Anshuman-Khandual/arm64-hugetlb-Reserve-CMA-areas-for-gigantic-pages-on-16K-and-64K-configs/20200629-144736
base:    9ebcfadb0610322ac537dd7aa5d9cbc2b2894c68
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm64

Quoted 8 lines

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

arch/arm64/mm/hugetlbpage.c:40:13: warning: no previous prototype for 'arm64_hugetlb_cma_reserve' [-Wmissing-prototypes]

40 | void __init arm64_hugetlb_cma_reserve(void)
| ^~~~~~~~~~~~~~~~~~~~~~~~~

This only comes up with W=1 and I wonder if this is truly a valid warning. Should all non-static function needs to have a declaration in a header file ? In this case, there is a declaration for this function near the call site itself, why should not that be sufficient.

#if defined(CONFIG_HUGETLB_PAGE) && defined(CONFIG_CMA) void arm64_hugetlb_cma_reserve(void); <--------- Declaration #else
static inline void arm64_hugetlb_cma_reserve(void) {
}
#endif

#3 lore raw
Quoted 47 lines

-----Original Message-----
From: Anshuman Khandual <[email protected]>
Sent: 2020年6月30日 9:05
To: lkp <[email protected]>; linux-mm(a)kvack.org
Cc: kbuild-all(a)lists.01.org; robin.murphy(a)arm.com; Catalin Marinas <[email protected]>; Will Deacon <[email protected]>; Mark Rutland <[email protected]>; Mike Kravetz <[email protected]>; Barry Song <[email protected]>; Andrew Morton <akpm@linux- foundation.org>
Subject: [kbuild-all] Re: [PATCH V2] arm64/hugetlb: Reserve CMA areas for gigantic pages on 16K and 64K configs

Quoted 4 lines · kernel test robot

Hi Anshuman,

Thank you for the patch! Perhaps something to improve:

Quoted 8 lines

[auto build test WARNING on v5.8-rc3]
[also build test WARNING on next-20200629] [cannot apply to arm64/for-next/core] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Anshuman-Khandual/arm64-

hugetlb-Reserve-CMA-areas-for-gigantic-pages-on-16K-and-64K- configs/20200629-144736

Quoted 5 lines

base: 9ebcfadb0610322ac537dd7aa5d9cbc2b2894c68
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0 reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-

tests/master/sbin/make.cross -O ~/bin/make.cross

Quoted 12 lines

chmod +x ~/bin/make.cross
# save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross
ARCH=arm64

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

Quoted 2 lines
Quoted 2 lines

arch/arm64/mm/hugetlbpage.c:40:13: warning: no previous prototype for 'arm64_hugetlb_cma_reserve' [-Wmissing-prototypes]

Quoted 7 lines
Quoted 2 lines

40 | void __init arm64_hugetlb_cma_reserve(void)
| ^~~~~~~~~~~~~~~~~~~~~~~~~

This only comes up with W=1 and I wonder if this is truly a valid warning. Should all non-static function needs to have a declaration in a header file ? In this case, there is a declaration for this function near the call site itself, why should not that be sufficient.

Yes, -Wmissing-prototypes only enabled when make W=1. Kindly refer to FAQ
https://github.com/intel/lkp-tests/wiki/LKP-FAQ#how-is-one-meant-to-act-on-w1-reports-like--wmissing-prototypes
please ignore this warning if confirmed it is not a issue here. sorry for inconvenient.

Quoted 7 lines

#if defined(CONFIG_HUGETLB_PAGE) && defined(CONFIG_CMA) void arm64_hugetlb_cma_reserve(void); <--------- Declaration #else static inline void arm64_hugetlb_cma_reserve(void) { } #endif
_______________________________________________
kbuild-all mailing list -- kbuild-all(a)lists.01.org To unsubscribe send an email to kbuild-all-leave(a)lists.01.org