Skip to contentSkip to conversation

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

RFC PATCH In review Aneesh Kumar K.V 2 participants 3 messages Apr 4, 2017 – Apr 5, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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

This patch adds support for gigantic pages in ppc64. We also updates gigantic_page_supported helper such that arch can override it.

---
 arch/powerpc/include/asm/book3s/64/hugetlb.h | 9 +++++++++
 arch/powerpc/mm/hugetlbpage.c                | 7 +++++--
 arch/powerpc/platforms/Kconfig.cputype       | 1 +
 mm/hugetlb.c                                 | 4 ++++
 4 files changed, 19 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/book3s/64/hugetlb.h +9 -0
index 6666cd366596..a994d069fdaf 100644
@@ -50,4 +50,13 @@ static inline pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma,
 	else
 		return entry;
 }
+
+#define gigantic_page_supported gigantic_page_supported
+static inline bool gigantic_page_supported(void)
+{
+	if (radix_enabled())
+		return true;
+	return false;
+}
+
 #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 a7c0c1fafe68..382c3dd86d6d 100644
@@ -343,6 +343,7 @@ config PPC_STD_MMU_64
 config PPC_RADIX_MMU
 	bool "Radix MMU Support"
 	depends on PPC_BOOK3S_64
+	select ARCH_HAS_GIGANTIC_PAGE
 	default y
 	help
 	  Enable support for the Power ISA 3.0 Radix style MMU. Currently this
mm/hugetlb.c +4 -0
index 3d0aab9ee80d..2c090189f314 100644
@@ -1158,7 +1158,11 @@ static int alloc_fresh_gigantic_page(struct hstate *h,
 	return 0;
 }
 
+#ifndef gigantic_page_supported
 static inline bool gigantic_page_supported(void) { return true; }
+#define gigantic_page_supported gigantic_page_supported
+#endif
+
 #else
 static inline bool gigantic_page_supported(void) { return false; }
 static inline void free_gigantic_page(struct page *page, unsigned int order) { }
Signature · 1 line
2.7.4
#1 lore raw
Quoted 2 lines · Aneesh Kumar K.V

This patch adds support for gigantic pages in ppc64. We also updates gigantic_page_supported helper such that arch can override it.

Seems like only radix based 1GB is considered as gigantic page in this implementation. What about the existing 16GB pages support ? IIUC they are still supported currently as gigantic pages (as defined in generic HugeTLB) if the platform gives us reserved memory areas during boot. Can you explain how this is going to be different ?

Quoted 15 lines
---
 arch/powerpc/include/asm/book3s/64/hugetlb.h | 9 +++++++++
 arch/powerpc/mm/hugetlbpage.c                | 7 +++++--
 arch/powerpc/platforms/Kconfig.cputype       | 1 +
 mm/hugetlb.c                                 | 4 ++++
 4 files changed, 19 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/book3s/64/hugetlb.h +0 -0
index 6666cd366596..a994d069fdaf 100644
@@ -50,4 +50,13 @@ static inline pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma,
 	else

arch/powerpc/include/asm/book3s/64/hugetlb.h static inline pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma, · line 60

Quoted 10 lines
arch/powerpc/include/asm/book3s/64/hugetlb.h +8 -0
 		return entry;
 }
+
+#define gigantic_page_supported gigantic_page_supported
+static inline bool gigantic_page_supported(void)
+{
+	if (radix_enabled())
+		return true;
+	return false;
+}

POWER8 (non radix MMU) cannot have 16GB gigantic HugeTLB pages ?

Quoted 7 lines
arch/powerpc/include/asm/book3s/64/hugetlb.h +1 -0
+
 #endif
arch/powerpc/mm/hugetlbpage.c +0 -0
index a4f33de4008e..80f6d2ed551a 100644

arch/powerpc/mm/hugetlbpage.c static int __init add_huge_page_size(unsigned long long size) · line 770

Quoted 10 lines
arch/powerpc/mm/hugetlbpage.c +5 -2
@@ -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;
+		}

The comment above this code block needs to be updated as well for this new page size addition. I understand that this code block was added to protect against wrong device tree supplied page size values but wondering dont we require one such check for normal page sizes as well (non HugeTLB) ? But anyways, thats a different topic.

#2 lore raw
Quoted 29 lines · Anshuman Khandual
Quoted 2 lines · Aneesh Kumar K.V

This patch adds support for gigantic pages in ppc64. We also updates gigantic_page_supported helper such that arch can override it.

Seems like only radix based 1GB is considered as gigantic page in this implementation. What about the existing 16GB pages support ? IIUC they are still supported currently as gigantic pages (as defined in generic HugeTLB) if the platform gives us reserved memory areas during boot. Can you explain how this is going to be different ?

Quoted 19 lines
---
 arch/powerpc/include/asm/book3s/64/hugetlb.h | 9 +++++++++
 arch/powerpc/mm/hugetlbpage.c                | 7 +++++--
 arch/powerpc/platforms/Kconfig.cputype       | 1 +
 mm/hugetlb.c                                 | 4 ++++
 4 files changed, 19 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/book3s/64/hugetlb.h +2 -0
index 6666cd366596..a994d069fdaf 100644
@@ -50,4 +50,13 @@ static inline pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma,
 	else
 		return entry;
 }
+
+#define gigantic_page_supported gigantic_page_supported
Quoted 8 lines

arch/powerpc/include/asm/book3s/64/hugetlb.h static inline pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma, · line 60

Quoted 6 lines
arch/powerpc/include/asm/book3s/64/hugetlb.h +6 -0
+static inline bool gigantic_page_supported(void)
+{
+	if (radix_enabled())
+		return true;
+	return false;
+}

POWER8 (non radix MMU) cannot have 16GB gigantic HugeTLB pages ?

that helper determines whether we can do gigantic page allocation at runtime. I doubt we can do that for 16GB pages. Hence this is only enabled for 1G radix config

-aneesh