linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@c-s.fr>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	aneesh.kumar@linux.ibm.com
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: [PATCH v1 17/27] powerpc/mm: cleanup HPAGE_SHIFT setup
Date: Wed, 20 Mar 2019 10:06:53 +0000 (UTC)	[thread overview]
Message-ID: <48261d1836013a82b9574b3d453e0b7a88d03ae5.1553076180.git.christophe.leroy@c-s.fr> (raw)
In-Reply-To: <cover.1553076180.git.christophe.leroy@c-s.fr>

Only book3s/64 may select default among several HPAGE_SHIFT at runtime.
8xx always defines 512K pages as default
FSL_BOOK3E always defines 4M pages as default

This patch limits HUGETLB_PAGE_SIZE_VARIABLE to book3s/64
moves the definitions in subarches files.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/Kconfig                 |  2 +-
 arch/powerpc/include/asm/hugetlb.h   |  2 ++
 arch/powerpc/include/asm/page.h      | 11 ++++++++---
 arch/powerpc/mm/hugetlbpage-hash64.c | 16 ++++++++++++++++
 arch/powerpc/mm/hugetlbpage.c        | 23 +++--------------------
 5 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 5d8e692d6470..7815eb0cc2a5 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -390,7 +390,7 @@ source "kernel/Kconfig.hz"
 
 config HUGETLB_PAGE_SIZE_VARIABLE
 	bool
-	depends on HUGETLB_PAGE
+	depends on HUGETLB_PAGE && PPC_BOOK3S_64
 	default y
 
 config MATH_EMULATION
diff --git a/arch/powerpc/include/asm/hugetlb.h b/arch/powerpc/include/asm/hugetlb.h
index 84598c6b0959..20a101046cff 100644
--- a/arch/powerpc/include/asm/hugetlb.h
+++ b/arch/powerpc/include/asm/hugetlb.h
@@ -15,6 +15,8 @@
 
 extern bool hugetlb_disabled;
 
+void hugetlbpage_init_default(void);
+
 void flush_dcache_icache_hugepage(struct page *page);
 
 int slice_is_hugepage_only_range(struct mm_struct *mm, unsigned long addr,
diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
index 0c11a7513919..eef10fe0e06f 100644
--- a/arch/powerpc/include/asm/page.h
+++ b/arch/powerpc/include/asm/page.h
@@ -28,10 +28,15 @@
 #define PAGE_SIZE		(ASM_CONST(1) << PAGE_SHIFT)
 
 #ifndef __ASSEMBLY__
-#ifdef CONFIG_HUGETLB_PAGE
-extern unsigned int HPAGE_SHIFT;
-#else
+#ifndef CONFIG_HUGETLB_PAGE
 #define HPAGE_SHIFT PAGE_SHIFT
+#elif defined(CONFIG_PPC_BOOK3S_64)
+extern unsigned int hpage_shift;
+#define HPAGE_SHIFT hpage_shift
+#elif defined(CONFIG_PPC_8xx)
+#define HPAGE_SHIFT		19	/* 512k pages */
+#elif defined(CONFIG_PPC_FSL_BOOK3E)
+#define HPAGE_SHIFT		22	/* 4M pages */
 #endif
 #define HPAGE_SIZE		((1UL) << HPAGE_SHIFT)
 #define HPAGE_MASK		(~(HPAGE_SIZE - 1))
diff --git a/arch/powerpc/mm/hugetlbpage-hash64.c b/arch/powerpc/mm/hugetlbpage-hash64.c
index b0d9209d9a86..7a58204c3688 100644
--- a/arch/powerpc/mm/hugetlbpage-hash64.c
+++ b/arch/powerpc/mm/hugetlbpage-hash64.c
@@ -15,6 +15,9 @@
 #include <asm/cacheflush.h>
 #include <asm/machdep.h>
 
+unsigned int hpage_shift;
+EXPORT_SYMBOL(hpage_shift);
+
 extern long hpte_insert_repeating(unsigned long hash, unsigned long vpn,
 				  unsigned long pa, unsigned long rlags,
 				  unsigned long vflags, int psize, int ssize);
@@ -145,3 +148,16 @@ void huge_ptep_modify_prot_commit(struct vm_area_struct *vma, unsigned long addr
 							   old_pte, pte);
 	set_huge_pte_at(vma->vm_mm, addr, ptep, pte);
 }
+
+void hugetlbpage_init_default(void)
+{
+	/* Set default large page size. Currently, we pick 16M or 1M
+	 * depending on what is available
+	 */
+	if (mmu_psize_defs[MMU_PAGE_16M].shift)
+		hpage_shift = mmu_psize_defs[MMU_PAGE_16M].shift;
+	else if (mmu_psize_defs[MMU_PAGE_1M].shift)
+		hpage_shift = mmu_psize_defs[MMU_PAGE_1M].shift;
+	else if (mmu_psize_defs[MMU_PAGE_2M].shift)
+		hpage_shift = mmu_psize_defs[MMU_PAGE_2M].shift;
+}
diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
index 3b449c9d4e47..dd62006e1243 100644
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -28,9 +28,6 @@
 
 bool hugetlb_disabled = false;
 
-unsigned int HPAGE_SHIFT;
-EXPORT_SYMBOL(HPAGE_SHIFT);
-
 #define hugepd_none(hpd)	(hpd_val(hpd) == 0)
 
 #define PTE_T_ORDER	(__builtin_ffs(sizeof(pte_t)) - __builtin_ffs(sizeof(void *)))
@@ -646,23 +643,9 @@ static int __init hugetlbpage_init(void)
 #endif
 	}
 
-#if defined(CONFIG_PPC_FSL_BOOK3E) || defined(CONFIG_PPC_8xx)
-	/* Default hpage size = 4M on FSL_BOOK3E and 512k on 8xx */
-	if (mmu_psize_defs[MMU_PAGE_4M].shift)
-		HPAGE_SHIFT = mmu_psize_defs[MMU_PAGE_4M].shift;
-	else if (mmu_psize_defs[MMU_PAGE_512K].shift)
-		HPAGE_SHIFT = mmu_psize_defs[MMU_PAGE_512K].shift;
-#else
-	/* Set default large page size. Currently, we pick 16M or 1M
-	 * depending on what is available
-	 */
-	if (mmu_psize_defs[MMU_PAGE_16M].shift)
-		HPAGE_SHIFT = mmu_psize_defs[MMU_PAGE_16M].shift;
-	else if (mmu_psize_defs[MMU_PAGE_1M].shift)
-		HPAGE_SHIFT = mmu_psize_defs[MMU_PAGE_1M].shift;
-	else if (mmu_psize_defs[MMU_PAGE_2M].shift)
-		HPAGE_SHIFT = mmu_psize_defs[MMU_PAGE_2M].shift;
-#endif
+	if (IS_ENABLED(HUGETLB_PAGE_SIZE_VARIABLE))
+		hugetlbpage_init_default();
+
 	return 0;
 }
 
-- 
2.13.3


  parent reply	other threads:[~2019-03-20 10:07 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-20 10:06 [PATCH v1 00/27] Reduce ifdef mess in hugetlbpage.c and slice.c Christophe Leroy
2019-03-20 10:06 ` [PATCH v1 01/27] powerpc/mm: Don't BUG() in hugepd_page() Christophe Leroy
2019-04-11  5:39   ` Aneesh Kumar K.V
2019-04-24 14:09     ` Christophe Leroy
2019-03-20 10:06 ` [PATCH v1 02/27] powerpc/mm: don't BUG in add_huge_page_size() Christophe Leroy
2019-04-11  5:41   ` Aneesh Kumar K.V
2019-04-24 14:09     ` Christophe Leroy
2019-03-20 10:06 ` [PATCH v1 03/27] powerpc/mm: don't BUG() in slice_mask_for_size() Christophe Leroy
2019-04-11  5:41   ` Aneesh Kumar K.V
2019-04-24 14:09     ` Christophe Leroy
2019-03-20 10:06 ` [PATCH v1 04/27] powerpc/book3e: drop mmu_get_tsize() Christophe Leroy
2019-03-20 10:06 ` [PATCH v1 05/27] powerpc/mm: drop slice_set_user_psize() Christophe Leroy
2019-03-20 10:06 ` [PATCH v1 06/27] powerpc/64: only book3s/64 supports CONFIG_PPC_64K_PAGES Christophe Leroy
2019-03-20 10:06 ` [PATCH v1 07/27] powerpc/book3e: hugetlbpage is only for CONFIG_PPC_FSL_BOOK3E Christophe Leroy
2019-03-20 10:06 ` [PATCH v1 08/27] powerpc/mm: move __find_linux_pte() out of hugetlbpage.c Christophe Leroy
2019-03-20 10:06 ` [PATCH v1 09/27] powerpc/mm: make hugetlbpage.c depend on CONFIG_HUGETLB_PAGE Christophe Leroy
2019-03-20 10:06 ` [PATCH v1 10/27] powerpc/mm: make gup_hugepte() static Christophe Leroy
2019-03-20 10:06 ` [PATCH v1 11/27] powerpc/mm: split asm/hugetlb.h into dedicated subarch files Christophe Leroy
2019-03-21 10:42   ` Christophe Leroy
2019-03-20 10:06 ` [PATCH v1 12/27] powerpc/mm: add a helper to populate hugepd Christophe Leroy
2019-03-20 10:06 ` [PATCH v1 13/27] powerpc/mm: define get_slice_psize() all the time Christophe Leroy
2019-03-20 10:06 ` [PATCH v1 14/27] powerpc/mm: no slice for nohash/64 Christophe Leroy
2019-03-20 10:06 ` [PATCH v1 15/27] powerpc/mm: cleanup ifdef mess in add_huge_page_size() Christophe Leroy
2019-03-20 10:06 ` [PATCH v1 16/27] powerpc/mm: move hugetlb_disabled into asm/hugetlb.h Christophe Leroy
2019-03-20 10:06 ` Christophe Leroy [this message]
2019-03-20 10:06 ` [PATCH v1 18/27] powerpc/mm: cleanup remaining ifdef mess in hugetlbpage.c Christophe Leroy
2019-03-20 10:06 ` [PATCH v1 19/27] powerpc/mm: drop slice DEBUG Christophe Leroy
2019-03-20 10:06 ` [PATCH v1 20/27] powerpc/mm: remove unnecessary #ifdef CONFIG_PPC64 Christophe Leroy
2019-03-20 10:06 ` [PATCH v1 21/27] powerpc/mm: hand a context_t over to slice_mask_for_size() instead of mm_struct Christophe Leroy
2019-03-20 10:06 ` [PATCH v1 22/27] powerpc/mm: move slice_mask_for_size() into mmu.h Christophe Leroy
2019-03-20 10:06 ` [PATCH v1 23/27] powerpc/mm: remove a couple of #ifdef CONFIG_PPC_64K_PAGES in mm/slice.c Christophe Leroy
2019-03-20 10:07 ` [PATCH v1 24/27] powerpc: define subarch SLB_ADDR_LIMIT_DEFAULT Christophe Leroy
2019-03-20 10:07 ` [PATCH v1 25/27] powerpc/mm: flatten function __find_linux_pte() Christophe Leroy
2019-03-20 10:07 ` [PATCH v1 26/27] powerpc/mm: flatten function __find_linux_pte() step 2 Christophe Leroy
2019-03-20 10:07 ` [PATCH v1 27/27] powerpc/mm: flatten function __find_linux_pte() step 3 Christophe Leroy
2019-03-21 10:44 ` [PATCH v1 00/27] Reduce ifdef mess in hugetlbpage.c and slice.c Christophe Leroy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48261d1836013a82b9574b3d453e0b7a88d03ae5.1553076180.git.christophe.leroy@c-s.fr \
    --to=christophe.leroy@c-s.fr \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=benh@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).