Skip to contentSkip to conversation

mm/hugetlb: Cleanup ARCH_HAS_GIGANTIC_PAGE

PATCH Applied Aneesh Kumar K.V 2 participants 6 messages May 17, 2017 – May 18, 2017

Subsystems (6)
Memory management x86 PowerPC arm64 +2 more subsystems
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 mm/hugetlb: Cleanup ARCH_HAS_GIGANTIC_PAGE

This moves the #ifdef in C code to a Kconfig dependency. Also we move the gigantic_page_supported() function to be arch specific. This gives arch to conditionally enable runtime allocation of gigantic huge page. Architectures like ppc64 supports different gigantic huge page size (16G and 1G) based on the translation mode selected. This provides an opportunity for ppc64 to enable runtime allocation only w.r.t 1G hugepage.

No functional change in this patch.

---
Changes from V2:
* Fix build error with x86
* Update the Kconfig change to match the C #ifdef

 arch/arm64/Kconfig               | 2 +-
 arch/arm64/include/asm/hugetlb.h | 4 ++++
 arch/s390/Kconfig                | 2 +-
 arch/s390/include/asm/hugetlb.h  | 3 +++
 arch/x86/Kconfig                 | 2 +-
 arch/x86/include/asm/hugetlb.h   | 4 ++++
 mm/hugetlb.c                     | 7 ++-----
 7 files changed, 16 insertions(+), 8 deletions(-)
arch/arm64/Kconfig +1 -1
index 3741859765cf..87240dcb6a07 100644
@@ -11,7 +11,7 @@ config ARM64
 	select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI
 	select ARCH_HAS_ELF_RANDOMIZE
 	select ARCH_HAS_GCOV_PROFILE_ALL
-	select ARCH_HAS_GIGANTIC_PAGE
+	select ARCH_HAS_GIGANTIC_PAGE if (MEMORY_ISOLATION && COMPACTION) || CMA
 	select ARCH_HAS_KCOV
 	select ARCH_HAS_SET_MEMORY
 	select ARCH_HAS_SG_CHAIN
arch/arm64/include/asm/hugetlb.h +4 -0
index bbc1e35aa601..793bd73b0d07 100644
@@ -83,4 +83,8 @@ extern void huge_ptep_set_wrprotect(struct mm_struct *mm,
 extern void huge_ptep_clear_flush(struct vm_area_struct *vma,
 				  unsigned long addr, pte_t *ptep);
 
+#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE
+static inline bool gigantic_page_supported(void) { return true; }
+#endif
+
 #endif /* __ASM_HUGETLB_H */
arch/s390/Kconfig +1 -1
index a2dcef0aacc7..f3637b641d7e 100644
@@ -67,7 +67,7 @@ config S390
 	select ARCH_HAS_DEVMEM_IS_ALLOWED
 	select ARCH_HAS_ELF_RANDOMIZE
 	select ARCH_HAS_GCOV_PROFILE_ALL
-	select ARCH_HAS_GIGANTIC_PAGE
+	select ARCH_HAS_GIGANTIC_PAGE if (MEMORY_ISOLATION && COMPACTION) || CMA
 	select ARCH_HAS_KCOV
 	select ARCH_HAS_SET_MEMORY
 	select ARCH_HAS_SG_CHAIN
arch/s390/include/asm/hugetlb.h +3 -0
index cd546a245c68..89057b2cc8fe 100644
@@ -112,4 +112,7 @@ static inline pte_t huge_pte_modify(pte_t pte, pgprot_t newprot)
 	return pte_modify(pte, newprot);
 }
 
+#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE
+static inline bool gigantic_page_supported(void) { return true; }
+#endif
 #endif /* _ASM_S390_HUGETLB_H */
arch/x86/Kconfig +1 -1
index cc98d5a294ee..e39b3b6b7d16 100644
@@ -22,7 +22,7 @@ config X86_64
 	def_bool y
 	depends on 64BIT
 	# Options that are inherently 64-bit kernel only:
-	select ARCH_HAS_GIGANTIC_PAGE
+	select ARCH_HAS_GIGANTIC_PAGE if (MEMORY_ISOLATION && COMPACTION) || CMA
 	select ARCH_SUPPORTS_INT128
 	select ARCH_USE_CMPXCHG_LOCKREF
 	select HAVE_ARCH_SOFT_DIRTY
arch/x86/include/asm/hugetlb.h +4 -0
index 3a106165e03a..535af0f2d8ac 100644
@@ -85,4 +85,8 @@ static inline void arch_clear_hugepage_flags(struct page *page)
 {
 }
 
+#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE
+static inline bool gigantic_page_supported(void) { return true; }
+#endif
+
 #endif /* _ASM_X86_HUGETLB_H */
mm/hugetlb.c +2 -5
index 3d0aab9ee80d..ce090186b992 100644
@@ -1024,9 +1024,7 @@ static int hstate_next_node_to_free(struct hstate *h, nodemask_t *nodes_allowed)
 		((node = hstate_next_node_to_free(hs, mask)) || 1);	\
 		nr_nodes--)
 
-#if defined(CONFIG_ARCH_HAS_GIGANTIC_PAGE) && \
-	((defined(CONFIG_MEMORY_ISOLATION) && defined(CONFIG_COMPACTION)) || \
-	defined(CONFIG_CMA))
+#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE
 static void destroy_compound_gigantic_page(struct page *page,
 					unsigned int order)
 {
@@ -1158,8 +1156,7 @@ static int alloc_fresh_gigantic_page(struct hstate *h,
 	return 0;
 }
 
-static inline bool gigantic_page_supported(void) { return true; }
-#else
+#else /* !CONFIG_ARCH_HAS_GIGANTIC_PAGE */
 static inline bool gigantic_page_supported(void) { return false; }
 static inline void free_gigantic_page(struct page *page, unsigned int order) { }
 static inline void destroy_compound_gigantic_page(struct page *page,
Signature · 7 lines
2.7.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw

PATCH v3 2/2 powerpc/mm/hugetlb: Add support for 1G huge pages

POWER9 supports hugepages of size 2M and 1G in radix MMU mode. This patch enables the usage of 1G page size for hugetlbfs. This also update the helper such we can do 1G page allocation at runtime.

We still don't enable 1G page size on DD1 version. This is to avoid doing workaround mentioned in commit: 6d3a0379ebdc8 (powerpc/mm: Add radix__tlb_flush_pte_p9_dd1()

---
 arch/powerpc/include/asm/book3s/64/hugetlb.h | 10 ++++++++++
 arch/powerpc/mm/hugetlbpage.c                |  7 +++++--
 arch/powerpc/platforms/Kconfig.cputype       |  1 +
 3 files changed, 16 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/book3s/64/hugetlb.h +10 -0
index 6666cd366596..5c28bd6f2ae1 100644
@@ -50,4 +50,14 @@ static inline pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma,
 	else
 		return entry;
 }
+
+#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE
+static inline bool gigantic_page_supported(void)
+{
+	if (radix_enabled())
+		return true;
+	return false;
+}
+#endif
+
 #endif
arch/powerpc/mm/hugetlbpage.c +5 -2
index a4f33de4008e..80f6d2ed551a 100644
@@ -763,8 +763,11 @@ static int __init add_huge_page_size(unsigned long long size)
 	 * Hash: 16M and 16G
 	 */
 	if (radix_enabled()) {
-		if (mmu_psize != MMU_PAGE_2M)
-			return -EINVAL;
+		if (mmu_psize != MMU_PAGE_2M) {
+			if (cpu_has_feature(CPU_FTR_POWER9_DD1) ||
+			    (mmu_psize != MMU_PAGE_1G))
+				return -EINVAL;
+		}
 	} else {
 		if (mmu_psize != MMU_PAGE_16M && mmu_psize != MMU_PAGE_16G)
 			return -EINVAL;
arch/powerpc/platforms/Kconfig.cputype +1 -0
index 684e886eaae4..b76ef6637016 100644
@@ -344,6 +344,7 @@ config PPC_STD_MMU_64
 config PPC_RADIX_MMU
 	bool "Radix MMU Support"
 	depends on PPC_BOOK3S_64
+	select ARCH_HAS_GIGANTIC_PAGE if (MEMORY_ISOLATION && COMPACTION) || CMA
 	default y
 	help
 	  Enable support for the Power ISA 3.0 Radix style MMU. Currently this
Signature · 7 lines
2.7.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#2 lore raw

Re: [PATCH v3 2/2] powerpc/mm/hugetlb: Add support for 1G huge pages

Quoted 8 lines · Aneesh Kumar K.V

POWER9 supports hugepages of size 2M and 1G in radix MMU mode. This patch enables the usage of 1G page size for hugetlbfs. This also update the helper such we can do 1G page allocation at runtime.

We still don't enable 1G page size on DD1 version. This is to avoid doing workaround mentioned in commit: 6d3a0379ebdc8 (powerpc/mm: Add radix__tlb_flush_pte_p9_dd1()

Quoted 6 lines
---
 arch/powerpc/include/asm/book3s/64/hugetlb.h | 10 ++++++++++
 arch/powerpc/mm/hugetlbpage.c                |  7 +++++--
 arch/powerpc/platforms/Kconfig.cputype       |  1 +
 3 files changed, 16 insertions(+), 2 deletions(-)

I think this patch is OK, but it's very confusing because it doesn't mention that it's only talking about *generic* gigantic page support.

We have existing support for gigantic pages on powerpc, on several platforms. This patch appears to break that, but I think doesn't in practice?

So can you make it a bit clearer in the commit message, and the code, that this is only about enabling the generic gigantic page support, and is unrelated to the arch-specific gigantic page support.

cheers

Quoted 51 lines
arch/powerpc/include/asm/book3s/64/hugetlb.h +10 -0
index 6666cd366596..5c28bd6f2ae1 100644
@@ -50,4 +50,14 @@ static inline pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma,
 	else
 		return entry;
 }
+
+#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE
+static inline bool gigantic_page_supported(void)
+{
+	if (radix_enabled())
+		return true;
+	return false;
+}
+#endif
+
 #endif
arch/powerpc/mm/hugetlbpage.c +5 -2
index a4f33de4008e..80f6d2ed551a 100644
@@ -763,8 +763,11 @@ static int __init add_huge_page_size(unsigned long long size)
 	 * Hash: 16M and 16G
 	 */
 	if (radix_enabled()) {
-		if (mmu_psize != MMU_PAGE_2M)
-			return -EINVAL;
+		if (mmu_psize != MMU_PAGE_2M) {
+			if (cpu_has_feature(CPU_FTR_POWER9_DD1) ||
+			    (mmu_psize != MMU_PAGE_1G))
+				return -EINVAL;
+		}
 	} else {
 		if (mmu_psize != MMU_PAGE_16M && mmu_psize != MMU_PAGE_16G)
 			return -EINVAL;
arch/powerpc/platforms/Kconfig.cputype +1 -0
index 684e886eaae4..b76ef6637016 100644
@@ -344,6 +344,7 @@ config PPC_STD_MMU_64
 config PPC_RADIX_MMU
 	bool "Radix MMU Support"
 	depends on PPC_BOOK3S_64
+	select ARCH_HAS_GIGANTIC_PAGE if (MEMORY_ISOLATION && COMPACTION) || CMA
 	default y
 	help
 	  Enable support for the Power ISA 3.0 Radix style MMU. Currently this
Signature · 1 line
2.7.4
#3 lore raw

Re: [PATCH v3 2/2] powerpc/mm/hugetlb: Add support for 1G huge pages

Quoted 17 lines · Michael Ellerman
Quoted 8 lines · Aneesh Kumar K.V

POWER9 supports hugepages of size 2M and 1G in radix MMU mode. This patch enables the usage of 1G page size for hugetlbfs. This also update the helper such we can do 1G page allocation at runtime.

We still don't enable 1G page size on DD1 version. This is to avoid doing workaround mentioned in commit: 6d3a0379ebdc8 (powerpc/mm: Add radix__tlb_flush_pte_p9_dd1()

Quoted 6 lines
---
  arch/powerpc/include/asm/book3s/64/hugetlb.h | 10 ++++++++++
  arch/powerpc/mm/hugetlbpage.c                |  7 +++++--
  arch/powerpc/platforms/Kconfig.cputype       |  1 +
  3 files changed, 16 insertions(+), 2 deletions(-)
Quoted 2 lines

I think this patch is OK, but it's very confusing because it doesn't mention that it's only talking about *generic* gigantic page support.

What you mean by generic gigantic page ? what is supported here is the gigantic page with size 1G alone ?

Quoted 5 lines

We have existing support for gigantic pages on powerpc, on several platforms. This patch appears to break that, but I think doesn't in practice?

What is broken ?

Quoted 49 lines

So can you make it a bit clearer in the commit message, and the code, that this is only about enabling the generic gigantic page support, and is unrelated to the arch-specific gigantic page support.

cheers

Quoted 43 lines
arch/powerpc/include/asm/book3s/64/hugetlb.h +10 -0
index 6666cd366596..5c28bd6f2ae1 100644
@@ -50,4 +50,14 @@ static inline pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma,
  	else
  		return entry;
  }
+
+#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE
+static inline bool gigantic_page_supported(void)
+{
+	if (radix_enabled())
+		return true;
+	return false;
+}
+#endif
+
  #endif
arch/powerpc/mm/hugetlbpage.c +5 -2
index a4f33de4008e..80f6d2ed551a 100644
@@ -763,8 +763,11 @@ static int __init add_huge_page_size(unsigned long long size)
  	 * Hash: 16M and 16G
  	 */
  	if (radix_enabled()) {
-		if (mmu_psize != MMU_PAGE_2M)
-			return -EINVAL;
+		if (mmu_psize != MMU_PAGE_2M) {
+			if (cpu_has_feature(CPU_FTR_POWER9_DD1) ||
+			    (mmu_psize != MMU_PAGE_1G))
+				return -EINVAL;
+		}
  	} else {
  		if (mmu_psize != MMU_PAGE_16M && mmu_psize != MMU_PAGE_16G)
  			return -EINVAL;
arch/powerpc/platforms/Kconfig.cputype +0 -0
index 684e886eaae4..b76ef6637016 100644
@@ -344,6 +344,7 @@ config PPC_STD_MMU_64
  config PPC_RADIX_MMU
Quoted 9 lines
Quoted 8 lines
arch/powerpc/platforms/Kconfig.cputype +1 -0
  	bool "Radix MMU Support"
  	depends on PPC_BOOK3S_64
+	select ARCH_HAS_GIGANTIC_PAGE if (MEMORY_ISOLATION && COMPACTION) || CMA
  	default y
  	help
  	  Enable support for the Power ISA 3.0 Radix style MMU. Currently this
Signature · 1 line
2.7.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#4 lore raw

Re: [PATCH v3 2/2] powerpc/mm/hugetlb: Add support for 1G huge pages

Quoted 18 lines · Aneesh Kumar K.V
Quoted 17 lines · Michael Ellerman
Quoted 14 lines · Aneesh Kumar K.V

POWER9 supports hugepages of size 2M and 1G in radix MMU mode. This patch enables the usage of 1G page size for hugetlbfs. This also update the helper such we can do 1G page allocation at runtime.

We still don't enable 1G page size on DD1 version. This is to avoid doing workaround mentioned in commit: 6d3a0379ebdc8 (powerpc/mm: Add radix__tlb_flush_pte_p9_dd1()

---
  arch/powerpc/include/asm/book3s/64/hugetlb.h | 10 ++++++++++
  arch/powerpc/mm/hugetlbpage.c                |  7 +++++--
  arch/powerpc/platforms/Kconfig.cputype       |  1 +
  3 files changed, 16 insertions(+), 2 deletions(-)
Quoted 5 lines
Quoted 2 lines

I think this patch is OK, but it's very confusing because it doesn't mention that it's only talking about *generic* gigantic page support.

What you mean by generic gigantic page ? what is supported here is the gigantic page with size 1G alone ?

What about 16G pages on pseries.

And all the other gigantic page sizes that Book3E supports?

cheers

#5 lore raw

Re: [PATCH v3 2/2] powerpc/mm/hugetlb: Add support for 1G huge pages

Quoted 23 lines · Michael Ellerman
Quoted 21 lines · Aneesh Kumar K.V
Quoted 19 lines · Michael Ellerman
Quoted 8 lines · Aneesh Kumar K.V

POWER9 supports hugepages of size 2M and 1G in radix MMU mode. This patch enables the usage of 1G page size for hugetlbfs. This also update the helper such we can do 1G page allocation at runtime.

We still don't enable 1G page size on DD1 version. This is to avoid doing workaround mentioned in commit: 6d3a0379ebdc8 (powerpc/mm: Add radix__tlb_flush_pte_p9_dd1()

Quoted 6 lines
---
   arch/powerpc/include/asm/book3s/64/hugetlb.h | 10 ++++++++++
   arch/powerpc/mm/hugetlbpage.c                |  7 +++++--
   arch/powerpc/platforms/Kconfig.cputype       |  1 +
   3 files changed, 16 insertions(+), 2 deletions(-)

I think this patch is OK, but it's very confusing because it doesn't mention that it's only talking about *generic* gigantic page support.

Quoted 7 lines
Quoted 2 lines

What you mean by generic gigantic page ? what is supported here is the gigantic page with size 1G alone ?

What about 16G pages on pseries.

And all the other gigantic page sizes that Book3E supports?

None of that is supported w.r.t runtime allocation of hugepages. ie, we cannot echo nr_hugepages w.r.t them. For 16GB i am not sure it make sense, because we will rarely get such large contiguous region. W.r.t page size supported for Book3E, may be we can. But I don't have a facility to test those. Hence didn't include that.

-aneesh

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>