Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1354070 > unrolled thread

[RFC 1/9] mm/hugetlb: Make GENERAL_HUGETLB functions PGD implementation aware

Started byAnshuman Khandual <khandual@linux.vnet.ibm.com>
First post2016-03-09 13:20 +0100
Last post2016-03-14 21:30 +0100
Articles 12 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [RFC 1/9] mm/hugetlb: Make GENERAL_HUGETLB functions PGD implementation aware Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2016-03-09 13:20 +0100
    [RFC 4/9] powerpc/mm: Split huge_pte_alloc function for BOOK3S 64K Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2016-03-09 13:20 +0100
      Re: [RFC 4/9] powerpc/mm: Split huge_pte_alloc function for BOOK3S 64K "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> - 2016-03-09 21:00 +0100
        Re: [RFC 4/9] powerpc/mm: Split huge_pte_alloc function for BOOK3S  64K Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2016-03-10 06:40 +0100
    [RFC 6/9] powerpc/hugetlb: Enable ARCH_WANT_GENERAL_HUGETLB for BOOK3S 64K Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2016-03-09 13:20 +0100
      Re: [RFC 6/9] powerpc/hugetlb: Enable ARCH_WANT_GENERAL_HUGETLB for BOOK3S 64K "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> - 2016-03-09 21:00 +0100
        Re: [RFC 6/9] powerpc/hugetlb: Enable ARCH_WANT_GENERAL_HUGETLB for  BOOK3S 64K Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2016-03-10 06:20 +0100
    [RFC 5/9] powerpc/mm: Split huge_pte_offset function for BOOK3S 64K Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2016-03-09 13:20 +0100
      Re: [RFC 5/9] powerpc/mm: Split huge_pte_offset function for BOOK3S  64K Dave Hansen <dave.hansen@intel.com> - 2016-03-10 00:00 +0100
        Re: [RFC 5/9] powerpc/mm: Split huge_pte_offset function for BOOK3S  64K Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2016-03-10 04:40 +0100
    Re: [RFC 1/9] mm/hugetlb: Make GENERAL_HUGETLB functions PGD implementation  aware Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2016-03-11 04:10 +0100
      Re: [RFC 1/9] mm/hugetlb: Make GENERAL_HUGETLB functions PGD  implementation aware Andrew Morton <akpm@linux-foundation.org> - 2016-03-14 21:30 +0100

#1354070 — [RFC 1/9] mm/hugetlb: Make GENERAL_HUGETLB functions PGD implementation aware

FromAnshuman Khandual <khandual@linux.vnet.ibm.com>
Date2016-03-09 13:20 +0100
Subject[RFC 1/9] mm/hugetlb: Make GENERAL_HUGETLB functions PGD implementation aware
Message-ID<raLfP-7Ms-3@gated-at.bofh.it>
Currently both the ARCH_WANT_GENERAL_HUGETLB functions 'huge_pte_alloc'
and 'huge_pte_offset' dont take into account huge page implementation
at the PGD level. With addition of PGD awareness into these functions,
more architectures like POWER which also implements huge pages at PGD
level (along with PMD level), can use ARCH_WANT_GENERAL_HUGETLB option.

Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
---
 mm/hugetlb.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 01f2b48..a478b7b 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4251,6 +4251,11 @@ pte_t *huge_pte_alloc(struct mm_struct *mm,
 	pte_t *pte = NULL;
 
 	pgd = pgd_offset(mm, addr);
+	if (sz == PGDIR_SIZE) {
+		pte = (pte_t *)pgd;
+		goto huge_pgd;
+	}
+
 	pud = pud_alloc(mm, pgd, addr);
 	if (pud) {
 		if (sz == PUD_SIZE) {
@@ -4263,6 +4268,8 @@ pte_t *huge_pte_alloc(struct mm_struct *mm,
 				pte = (pte_t *)pmd_alloc(mm, pud, addr);
 		}
 	}
+
+huge_pgd:
 	BUG_ON(pte && !pte_none(*pte) && !pte_huge(*pte));
 
 	return pte;
@@ -4276,6 +4283,8 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
 
 	pgd = pgd_offset(mm, addr);
 	if (pgd_present(*pgd)) {
+		if (pgd_huge(*pgd))
+			return (pte_t *)pgd;
 		pud = pud_offset(pgd, addr);
 		if (pud_present(*pud)) {
 			if (pud_huge(*pud))
-- 
2.1.0

[toc] | [next] | [standalone]


#1354071 — [RFC 4/9] powerpc/mm: Split huge_pte_alloc function for BOOK3S 64K

FromAnshuman Khandual <khandual@linux.vnet.ibm.com>
Date2016-03-09 13:20 +0100
Subject[RFC 4/9] powerpc/mm: Split huge_pte_alloc function for BOOK3S 64K
Message-ID<raLfR-7Ms-37@gated-at.bofh.it>
In reply to#1354070
From: root <root@ltcalpine2-lp8.aus.stglabs.ibm.com>

Currently the 'huge_pte_alloc' function has two versions, one for the
BOOK3S and the other one for the BOOK3E platforms. This change splits
the BOOK3S version into two parts, one for the 4K page size based
implementation and the other one for the 64K page sized implementation.
This change is one of the prerequisites towards enabling GENERAL_HUGETLB
implementation for BOOK3S 64K based huge pages.

Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
---
 arch/powerpc/mm/hugetlbpage.c | 67 +++++++++++++++++++++++++++----------------
 1 file changed, 43 insertions(+), 24 deletions(-)

diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
index 744e24b..a49c6ae 100644
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -59,6 +59,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
 	return __find_linux_pte_or_hugepte(mm->pgd, addr, NULL, NULL);
 }
 
+#if !defined(CONFIG_PPC_64K_PAGES) || !defined(CONFIG_PPC_BOOK3S_64)
 static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,
 			   unsigned long address, unsigned pdshift, unsigned pshift)
 {
@@ -117,6 +118,7 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,
 	spin_unlock(&mm->page_table_lock);
 	return 0;
 }
+#endif /* !defined(CONFIG_PPC_64K_PAGES) || !defined(CONFIG_PPC_BOOK3S_64) */
 
 /*
  * These macros define how to determine which level of the page table holds
@@ -131,6 +133,7 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,
 #endif
 
 #ifdef CONFIG_PPC_BOOK3S_64
+#ifdef CONFIG_PPC_4K_PAGES
 /*
  * At this point we do the placement change only for BOOK3S 64. This would
  * possibly work on other subarchs.
@@ -146,32 +149,23 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long sz
 
 	addr &= ~(sz-1);
 	pg = pgd_offset(mm, addr);
-
-	if (pshift == PGDIR_SHIFT)
-		/* 16GB huge page */
-		return (pte_t *) pg;
-	else if (pshift > PUD_SHIFT)
-		/*
-		 * We need to use hugepd table
-		 */
+	if (pshift > PUD_SHIFT) {
 		hpdp = (hugepd_t *)pg;
-	else {
-		pdshift = PUD_SHIFT;
-		pu = pud_alloc(mm, pg, addr);
-		if (pshift == PUD_SHIFT)
-			return (pte_t *)pu;
-		else if (pshift > PMD_SHIFT)
-			hpdp = (hugepd_t *)pu;
-		else {
-			pdshift = PMD_SHIFT;
-			pm = pmd_alloc(mm, pu, addr);
-			if (pshift == PMD_SHIFT)
-				/* 16MB hugepage */
-				return (pte_t *)pm;
-			else
-				hpdp = (hugepd_t *)pm;
-		}
+		goto hugepd_search;
+	}
+
+	pdshift = PUD_SHIFT;
+	pu = pud_alloc(mm, pg, addr);
+	if (pshift > PMD_SHIFT) {
+		hpdp = (hugepd_t *)pu;
+		goto hugepd_search;
 	}
+
+	pdshift = PMD_SHIFT;
+	pm = pmd_alloc(mm, pu, addr);
+	hpdp = (hugepd_t *)pm;
+
+hugepd_search:
 	if (!hpdp)
 		return NULL;
 
@@ -184,6 +178,31 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long sz
 }
 
 #else
+pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long sz)
+{
+	pgd_t *pg;
+	pud_t *pu;
+	pmd_t *pm;
+	unsigned pshift = __ffs(sz);
+
+	addr &= ~(sz-1);
+	pg = pgd_offset(mm, addr);
+
+	if (pshift == PGDIR_SHIFT)	/* 16GB Huge Page */
+		return (pte_t *)pg;
+
+	pu = pud_alloc(mm, pg, addr);	/* NA, skipped */
+	if (pshift == PUD_SHIFT)
+		return (pte_t *)pu;
+
+	pm = pmd_alloc(mm, pu, addr);	/* 16MB Huge Page */
+	if (pshift == PMD_SHIFT)
+		return (pte_t *)pm;
+
+	return NULL;
+}
+#endif
+#else
 
 pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long sz)
 {
-- 
2.1.0

[toc] | [prev] | [next] | [standalone]


#1354399 — Re: [RFC 4/9] powerpc/mm: Split huge_pte_alloc function for BOOK3S 64K

From"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Date2016-03-09 21:00 +0100
SubjectRe: [RFC 4/9] powerpc/mm: Split huge_pte_alloc function for BOOK3S 64K
Message-ID<raSqZ-4bO-17@gated-at.bofh.it>
In reply to#1354071
Anshuman Khandual <khandual@linux.vnet.ibm.com> writes:

> [ text/plain ]
> From: root <root@ltcalpine2-lp8.aus.stglabs.ibm.com>
>
> Currently the 'huge_pte_alloc' function has two versions, one for the
> BOOK3S and the other one for the BOOK3E platforms. This change splits
> the BOOK3S version into two parts, one for the 4K page size based
> implementation and the other one for the 64K page sized implementation.
> This change is one of the prerequisites towards enabling GENERAL_HUGETLB
> implementation for BOOK3S 64K based huge pages.

I really wish we reduce #ifdefs in C code and start splitting hash
and nonhash code out where ever we can. 

What we really want here is a book3s version and in book3s version use
powerpc specific huge_pte_alloc only if GENERAL_HUGETLB was not defined.
Don't limit it to 64k linux page size. We should select between powerpc
specific implementation and generic code using GENERAL_HUGETLB define.


>
> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
> ---
>  arch/powerpc/mm/hugetlbpage.c | 67 +++++++++++++++++++++++++++----------------
>  1 file changed, 43 insertions(+), 24 deletions(-)
>
> diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
> index 744e24b..a49c6ae 100644
> --- a/arch/powerpc/mm/hugetlbpage.c
> +++ b/arch/powerpc/mm/hugetlbpage.c
> @@ -59,6 +59,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
>  	return __find_linux_pte_or_hugepte(mm->pgd, addr, NULL, NULL);
>  }
>
> +#if !defined(CONFIG_PPC_64K_PAGES) || !defined(CONFIG_PPC_BOOK3S_64)
>  static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,
>  			   unsigned long address, unsigned pdshift, unsigned pshift)
>  {
> @@ -117,6 +118,7 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,
>  	spin_unlock(&mm->page_table_lock);
>  	return 0;
>  }
> +#endif /* !defined(CONFIG_PPC_64K_PAGES) || !defined(CONFIG_PPC_BOOK3S_64) */
>
>  /*
>   * These macros define how to determine which level of the page table holds
> @@ -131,6 +133,7 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,
>  #endif
>
>  #ifdef CONFIG_PPC_BOOK3S_64
> +#ifdef CONFIG_PPC_4K_PAGES
>  /*
>   * At this point we do the placement change only for BOOK3S 64. This would
>   * possibly work on other subarchs.
> @@ -146,32 +149,23 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long sz
>
>  	addr &= ~(sz-1);
>  	pg = pgd_offset(mm, addr);
> -
> -	if (pshift == PGDIR_SHIFT)
> -		/* 16GB huge page */
> -		return (pte_t *) pg;
> -	else if (pshift > PUD_SHIFT)
> -		/*
> -		 * We need to use hugepd table
> -		 */
> +	if (pshift > PUD_SHIFT) {
>  		hpdp = (hugepd_t *)pg;
> -	else {
> -		pdshift = PUD_SHIFT;
> -		pu = pud_alloc(mm, pg, addr);
> -		if (pshift == PUD_SHIFT)
> -			return (pte_t *)pu;
> -		else if (pshift > PMD_SHIFT)
> -			hpdp = (hugepd_t *)pu;
> -		else {
> -			pdshift = PMD_SHIFT;
> -			pm = pmd_alloc(mm, pu, addr);
> -			if (pshift == PMD_SHIFT)
> -				/* 16MB hugepage */
> -				return (pte_t *)pm;
> -			else
> -				hpdp = (hugepd_t *)pm;
> -		}
> +		goto hugepd_search;
> +	}
> +
> +	pdshift = PUD_SHIFT;
> +	pu = pud_alloc(mm, pg, addr);
> +	if (pshift > PMD_SHIFT) {
> +		hpdp = (hugepd_t *)pu;
> +		goto hugepd_search;
>  	}
> +
> +	pdshift = PMD_SHIFT;
> +	pm = pmd_alloc(mm, pu, addr);
> +	hpdp = (hugepd_t *)pm;
> +
> +hugepd_search:
>  	if (!hpdp)
>  		return NULL;
>
> @@ -184,6 +178,31 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long sz
>  }
>
>  #else
> +pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long sz)
> +{
> +	pgd_t *pg;
> +	pud_t *pu;
> +	pmd_t *pm;
> +	unsigned pshift = __ffs(sz);
> +
> +	addr &= ~(sz-1);
> +	pg = pgd_offset(mm, addr);
> +
> +	if (pshift == PGDIR_SHIFT)	/* 16GB Huge Page */
> +		return (pte_t *)pg;
> +
> +	pu = pud_alloc(mm, pg, addr);	/* NA, skipped */
> +	if (pshift == PUD_SHIFT)
> +		return (pte_t *)pu;
> +
> +	pm = pmd_alloc(mm, pu, addr);	/* 16MB Huge Page */
> +	if (pshift == PMD_SHIFT)
> +		return (pte_t *)pm;
> +
> +	return NULL;
> +}
> +#endif
> +#else
>
>  pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long sz)
>  {
> -- 
> 2.1.0

[toc] | [prev] | [next] | [standalone]


#1354868 — Re: [RFC 4/9] powerpc/mm: Split huge_pte_alloc function for BOOK3S 64K

FromAnshuman Khandual <khandual@linux.vnet.ibm.com>
Date2016-03-10 06:40 +0100
SubjectRe: [RFC 4/9] powerpc/mm: Split huge_pte_alloc function for BOOK3S 64K
Message-ID<rb1uh-2rw-1@gated-at.bofh.it>
In reply to#1354399
On 03/10/2016 01:25 AM, Aneesh Kumar K.V wrote:
> Anshuman Khandual <khandual@linux.vnet.ibm.com> writes:
> 
>> > [ text/plain ]
>> > From: root <root@ltcalpine2-lp8.aus.stglabs.ibm.com>
>> >
>> > Currently the 'huge_pte_alloc' function has two versions, one for the
>> > BOOK3S and the other one for the BOOK3E platforms. This change splits
>> > the BOOK3S version into two parts, one for the 4K page size based
>> > implementation and the other one for the 64K page sized implementation.
>> > This change is one of the prerequisites towards enabling GENERAL_HUGETLB
>> > implementation for BOOK3S 64K based huge pages.
> I really wish we reduce #ifdefs in C code and start splitting hash
> and nonhash code out where ever we can.

Okay but here we are only dealing with 64K and 4K configs inside book3s.
I guess it covers both hash and no hash implementations. Not sure if I
got it correctly.

> 
> What we really want here is a book3s version and in book3s version use
> powerpc specific huge_pte_alloc only if GENERAL_HUGETLB was not defined.

got it.

> Don't limit it to 64k linux page size. We should select between powerpc
> specific implementation and generic code using GENERAL_HUGETLB define.

Got it. will try.

[toc] | [prev] | [next] | [standalone]


#1354072 — [RFC 6/9] powerpc/hugetlb: Enable ARCH_WANT_GENERAL_HUGETLB for BOOK3S 64K

FromAnshuman Khandual <khandual@linux.vnet.ibm.com>
Date2016-03-09 13:20 +0100
Subject[RFC 6/9] powerpc/hugetlb: Enable ARCH_WANT_GENERAL_HUGETLB for BOOK3S 64K
Message-ID<raLfR-7Ms-45@gated-at.bofh.it>
In reply to#1354070
This enables ARCH_WANT_GENERAL_HUGETLB for BOOK3S 64K in Kconfig.
It also implements a new function 'pte_huge' which is required by
function 'huge_pte_alloc' from generic VM. Existing BOOK3S 64K
specific functions 'huge_pte_alloc' and 'huge_pte_offset' (which
are no longer required) are removed with this change.

Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
---
 arch/powerpc/Kconfig                          |  4 ++
 arch/powerpc/include/asm/book3s/64/hash-64k.h |  8 ++++
 arch/powerpc/mm/hugetlbpage.c                 | 60 ---------------------------
 3 files changed, 12 insertions(+), 60 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 9faa18c..c6920bb 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -33,6 +33,10 @@ config HAVE_SETUP_PER_CPU_AREA
 config NEED_PER_CPU_EMBED_FIRST_CHUNK
 	def_bool PPC64
 
+config ARCH_WANT_GENERAL_HUGETLB
+	depends on PPC_64K_PAGES && PPC_BOOK3S_64
+	def_bool y
+
 config NR_IRQS
 	int "Number of virtual interrupt numbers"
 	range 32 32768
diff --git a/arch/powerpc/include/asm/book3s/64/hash-64k.h b/arch/powerpc/include/asm/book3s/64/hash-64k.h
index 849bbec..5e9b9b9 100644
--- a/arch/powerpc/include/asm/book3s/64/hash-64k.h
+++ b/arch/powerpc/include/asm/book3s/64/hash-64k.h
@@ -143,6 +143,14 @@ extern bool __rpte_sub_valid(real_pte_t rpte, unsigned long index);
  * Defined in such a way that we can optimize away code block at build time
  * if CONFIG_HUGETLB_PAGE=n.
  */
+static inline int pte_huge(pte_t pte)
+{
+	/*
+	 * leaf pte for huge page
+	 */
+	return !!(pte_val(pte) & _PAGE_PTE);
+}
+
 static inline int pmd_huge(pmd_t pmd)
 {
 	/*
diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
index f834a74..f6e4712 100644
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -59,42 +59,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
 	/* Only called for hugetlbfs pages, hence can ignore THP */
 	return __find_linux_pte_or_hugepte(mm->pgd, addr, NULL, NULL);
 }
-#else
-pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
-{
-	pgd_t pgd, *pgdp;
-	pud_t pud, *pudp;
-	pmd_t pmd, *pmdp;
-
-	pgdp = mm->pgd + pgd_index(addr);
-	pgd  = READ_ONCE(*pgdp);
-
-	if (pgd_none(pgd))
-		return NULL;
-
-	if (pgd_huge(pgd))
-		return (pte_t *)pgdp;
-
-	pudp = pud_offset(&pgd, addr);
-	pud  = READ_ONCE(*pudp);
-	if (pud_none(pud))
-		return NULL;
-
-	if (pud_huge(pud))
-		return (pte_t *)pudp;
 
-	pmdp = pmd_offset(&pud, addr);
-	pmd  = READ_ONCE(*pmdp);
-	if (pmd_none(pmd))
-		return NULL;
-
-	if (pmd_huge(pmd))
-		return (pte_t *)pmdp;
-	return NULL;
-}
-#endif /* !defined(CONFIG_PPC_64K_PAGES) || !defined(CONFIG_PPC_BOOK3S_64) */
-
-#if !defined(CONFIG_PPC_64K_PAGES) || !defined(CONFIG_PPC_BOOK3S_64)
 static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,
 			   unsigned long address, unsigned pdshift, unsigned pshift)
 {
@@ -211,31 +176,6 @@ hugepd_search:
 
 	return hugepte_offset(*hpdp, addr, pdshift);
 }
-
-#else
-pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long sz)
-{
-	pgd_t *pg;
-	pud_t *pu;
-	pmd_t *pm;
-	unsigned pshift = __ffs(sz);
-
-	addr &= ~(sz-1);
-	pg = pgd_offset(mm, addr);
-
-	if (pshift == PGDIR_SHIFT)	/* 16GB Huge Page */
-		return (pte_t *)pg;
-
-	pu = pud_alloc(mm, pg, addr);	/* NA, skipped */
-	if (pshift == PUD_SHIFT)
-		return (pte_t *)pu;
-
-	pm = pmd_alloc(mm, pu, addr);	/* 16MB Huge Page */
-	if (pshift == PMD_SHIFT)
-		return (pte_t *)pm;
-
-	return NULL;
-}
 #endif
 #else
 
-- 
2.1.0

[toc] | [prev] | [next] | [standalone]


#1354408 — Re: [RFC 6/9] powerpc/hugetlb: Enable ARCH_WANT_GENERAL_HUGETLB for BOOK3S 64K

From"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Date2016-03-09 21:00 +0100
SubjectRe: [RFC 6/9] powerpc/hugetlb: Enable ARCH_WANT_GENERAL_HUGETLB for BOOK3S 64K
Message-ID<raSr1-4bO-53@gated-at.bofh.it>
In reply to#1354072
Anshuman Khandual <khandual@linux.vnet.ibm.com> writes:

> [ text/plain ]
> This enables ARCH_WANT_GENERAL_HUGETLB for BOOK3S 64K in Kconfig.
> It also implements a new function 'pte_huge' which is required by
> function 'huge_pte_alloc' from generic VM. Existing BOOK3S 64K
> specific functions 'huge_pte_alloc' and 'huge_pte_offset' (which
> are no longer required) are removed with this change.
>

You want this to be the last patch isn't it ? And you are mixing too
many things in this patch. Why not do this

* book3s specific hash pte routines
* book3s add conditional based on GENERAL_HUGETLB
* Enable GENERAL_HUGETLB for 64k page size config

> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
> ---
>  arch/powerpc/Kconfig                          |  4 ++
>  arch/powerpc/include/asm/book3s/64/hash-64k.h |  8 ++++
>  arch/powerpc/mm/hugetlbpage.c                 | 60 ---------------------------
>  3 files changed, 12 insertions(+), 60 deletions(-)
>
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 9faa18c..c6920bb 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -33,6 +33,10 @@ config HAVE_SETUP_PER_CPU_AREA
>  config NEED_PER_CPU_EMBED_FIRST_CHUNK
>  	def_bool PPC64
>
> +config ARCH_WANT_GENERAL_HUGETLB
> +	depends on PPC_64K_PAGES && PPC_BOOK3S_64
> +	def_bool y
> +
>  config NR_IRQS
>  	int "Number of virtual interrupt numbers"
>  	range 32 32768
> diff --git a/arch/powerpc/include/asm/book3s/64/hash-64k.h b/arch/powerpc/include/asm/book3s/64/hash-64k.h
> index 849bbec..5e9b9b9 100644
> --- a/arch/powerpc/include/asm/book3s/64/hash-64k.h
> +++ b/arch/powerpc/include/asm/book3s/64/hash-64k.h
> @@ -143,6 +143,14 @@ extern bool __rpte_sub_valid(real_pte_t rpte, unsigned long index);
>   * Defined in such a way that we can optimize away code block at build time
>   * if CONFIG_HUGETLB_PAGE=n.
>   */
> +static inline int pte_huge(pte_t pte)
> +{
> +	/*
> +	 * leaf pte for huge page
> +	 */
> +	return !!(pte_val(pte) & _PAGE_PTE);
> +}
> +
>  static inline int pmd_huge(pmd_t pmd)
>  {
>  	/*
> diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
> index f834a74..f6e4712 100644
> --- a/arch/powerpc/mm/hugetlbpage.c
> +++ b/arch/powerpc/mm/hugetlbpage.c
> @@ -59,42 +59,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
>  	/* Only called for hugetlbfs pages, hence can ignore THP */
>  	return __find_linux_pte_or_hugepte(mm->pgd, addr, NULL, NULL);
>  }
> -#else
> -pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
> -{
> -	pgd_t pgd, *pgdp;
> -	pud_t pud, *pudp;
> -	pmd_t pmd, *pmdp;
> -
> -	pgdp = mm->pgd + pgd_index(addr);
> -	pgd  = READ_ONCE(*pgdp);
> -
> -	if (pgd_none(pgd))
> -		return NULL;
> -
> -	if (pgd_huge(pgd))
> -		return (pte_t *)pgdp;
> -
> -	pudp = pud_offset(&pgd, addr);
> -	pud  = READ_ONCE(*pudp);
> -	if (pud_none(pud))
> -		return NULL;
> -
> -	if (pud_huge(pud))
> -		return (pte_t *)pudp;
>
> -	pmdp = pmd_offset(&pud, addr);
> -	pmd  = READ_ONCE(*pmdp);
> -	if (pmd_none(pmd))
> -		return NULL;
> -
> -	if (pmd_huge(pmd))
> -		return (pte_t *)pmdp;
> -	return NULL;
> -}
> -#endif /* !defined(CONFIG_PPC_64K_PAGES) || !defined(CONFIG_PPC_BOOK3S_64) */
> -
> -#if !defined(CONFIG_PPC_64K_PAGES) || !defined(CONFIG_PPC_BOOK3S_64)
>  static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,
>  			   unsigned long address, unsigned pdshift, unsigned pshift)
>  {
> @@ -211,31 +176,6 @@ hugepd_search:
>
>  	return hugepte_offset(*hpdp, addr, pdshift);
>  }
> -
> -#else
> -pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long sz)
> -{
> -	pgd_t *pg;
> -	pud_t *pu;
> -	pmd_t *pm;
> -	unsigned pshift = __ffs(sz);
> -
> -	addr &= ~(sz-1);
> -	pg = pgd_offset(mm, addr);
> -
> -	if (pshift == PGDIR_SHIFT)	/* 16GB Huge Page */
> -		return (pte_t *)pg;
> -
> -	pu = pud_alloc(mm, pg, addr);	/* NA, skipped */
> -	if (pshift == PUD_SHIFT)
> -		return (pte_t *)pu;
> -
> -	pm = pmd_alloc(mm, pu, addr);	/* 16MB Huge Page */
> -	if (pshift == PMD_SHIFT)
> -		return (pte_t *)pm;
> -
> -	return NULL;
> -}
>  #endif
>  #else
>
> -- 
> 2.1.0

[toc] | [prev] | [next] | [standalone]


#1354863 — Re: [RFC 6/9] powerpc/hugetlb: Enable ARCH_WANT_GENERAL_HUGETLB for BOOK3S 64K

FromAnshuman Khandual <khandual@linux.vnet.ibm.com>
Date2016-03-10 06:20 +0100
SubjectRe: [RFC 6/9] powerpc/hugetlb: Enable ARCH_WANT_GENERAL_HUGETLB for BOOK3S 64K
Message-ID<rb1aV-2gi-1@gated-at.bofh.it>
In reply to#1354408
On 03/10/2016 01:28 AM, Aneesh Kumar K.V wrote:
> Anshuman Khandual <khandual@linux.vnet.ibm.com> writes:
> 
>> > [ text/plain ]
>> > This enables ARCH_WANT_GENERAL_HUGETLB for BOOK3S 64K in Kconfig.
>> > It also implements a new function 'pte_huge' which is required by
>> > function 'huge_pte_alloc' from generic VM. Existing BOOK3S 64K
>> > specific functions 'huge_pte_alloc' and 'huge_pte_offset' (which
>> > are no longer required) are removed with this change.
>> >
> You want this to be the last patch isn't it ? And you are mixing too

Yeah, it should be the last one.

> many things in this patch. Why not do this
> 
> * book3s specific hash pte routines
> * book3s add conditional based on GENERAL_HUGETLB
> * Enable GENERAL_HUGETLB for 64k page size config

which creates three separate patches ?

[toc] | [prev] | [next] | [standalone]


#1354073 — [RFC 5/9] powerpc/mm: Split huge_pte_offset function for BOOK3S 64K

FromAnshuman Khandual <khandual@linux.vnet.ibm.com>
Date2016-03-09 13:20 +0100
Subject[RFC 5/9] powerpc/mm: Split huge_pte_offset function for BOOK3S 64K
Message-ID<raLfR-7Ms-49@gated-at.bofh.it>
In reply to#1354070
Currently the 'huge_pte_offset' function has only one version for
all the configuations and platforms. This change splits the function
into two versions, one for 64K page size based BOOK3S implementation
and the other one for everything else. This change is also one of the
prerequisites towards enabling GENERAL_HUGETLB implementation for
BOOK3S 64K based huge pages.

Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
---
 arch/powerpc/mm/hugetlbpage.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
index a49c6ae..f834a74 100644
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -53,11 +53,46 @@ static unsigned nr_gpages;
 
 #define hugepd_none(hpd)	((hpd).pd == 0)
 
+#if !defined(CONFIG_PPC_64K_PAGES) || !defined(CONFIG_PPC_BOOK3S_64)
 pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
 {
 	/* Only called for hugetlbfs pages, hence can ignore THP */
 	return __find_linux_pte_or_hugepte(mm->pgd, addr, NULL, NULL);
 }
+#else
+pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
+{
+	pgd_t pgd, *pgdp;
+	pud_t pud, *pudp;
+	pmd_t pmd, *pmdp;
+
+	pgdp = mm->pgd + pgd_index(addr);
+	pgd  = READ_ONCE(*pgdp);
+
+	if (pgd_none(pgd))
+		return NULL;
+
+	if (pgd_huge(pgd))
+		return (pte_t *)pgdp;
+
+	pudp = pud_offset(&pgd, addr);
+	pud  = READ_ONCE(*pudp);
+	if (pud_none(pud))
+		return NULL;
+
+	if (pud_huge(pud))
+		return (pte_t *)pudp;
+
+	pmdp = pmd_offset(&pud, addr);
+	pmd  = READ_ONCE(*pmdp);
+	if (pmd_none(pmd))
+		return NULL;
+
+	if (pmd_huge(pmd))
+		return (pte_t *)pmdp;
+	return NULL;
+}
+#endif /* !defined(CONFIG_PPC_64K_PAGES) || !defined(CONFIG_PPC_BOOK3S_64) */
 
 #if !defined(CONFIG_PPC_64K_PAGES) || !defined(CONFIG_PPC_BOOK3S_64)
 static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,
-- 
2.1.0

[toc] | [prev] | [next] | [standalone]


#1354540 — Re: [RFC 5/9] powerpc/mm: Split huge_pte_offset function for BOOK3S 64K

FromDave Hansen <dave.hansen@intel.com>
Date2016-03-10 00:00 +0100
SubjectRe: [RFC 5/9] powerpc/mm: Split huge_pte_offset function for BOOK3S 64K
Message-ID<raVfc-6nT-17@gated-at.bofh.it>
In reply to#1354073
On 03/09/2016 04:10 AM, Anshuman Khandual wrote:
> Currently the 'huge_pte_offset' function has only one version for
> all the configuations and platforms. This change splits the function
> into two versions, one for 64K page size based BOOK3S implementation
> and the other one for everything else. This change is also one of the
> prerequisites towards enabling GENERAL_HUGETLB implementation for
> BOOK3S 64K based huge pages.

I think there's a bit of background missing here for random folks on
linux-mm to make sense of these patches.

What is BOOK3S and what does it mean for these patches?  Why is its 64K
page size implementation different than all the others?  Is there a 4K
page size BOOK3S?

[toc] | [prev] | [next] | [standalone]


#1354825 — Re: [RFC 5/9] powerpc/mm: Split huge_pte_offset function for BOOK3S 64K

FromAnshuman Khandual <khandual@linux.vnet.ibm.com>
Date2016-03-10 04:40 +0100
SubjectRe: [RFC 5/9] powerpc/mm: Split huge_pte_offset function for BOOK3S 64K
Message-ID<raZC9-10L-3@gated-at.bofh.it>
In reply to#1354540
On 03/10/2016 04:27 AM, Dave Hansen wrote:
> On 03/09/2016 04:10 AM, Anshuman Khandual wrote:
>> > Currently the 'huge_pte_offset' function has only one version for
>> > all the configuations and platforms. This change splits the function
>> > into two versions, one for 64K page size based BOOK3S implementation
>> > and the other one for everything else. This change is also one of the
>> > prerequisites towards enabling GENERAL_HUGETLB implementation for
>> > BOOK3S 64K based huge pages.
> I think there's a bit of background missing here for random folks on
> linux-mm to make sense of these patches.
> 
> What is BOOK3S and what does it mean for these patches?  Why is its 64K

BOOK3S is the server type in powerpc family of processors which can support
multiple base page sizes like 64K and 4K.

> page size implementation different than all the others?  Is there a 4K
> page size BOOK3S?

It supports huge pages of size 16M as well as 16G and their implementations
are different with respect to base page sizes of 64K and 4K.

Patches 1, 2 and 3 are generic VM changes and the rest are powerpc specific
changes. Should I have split them accordingly and send out differently for
generic and powerpc specific reviews ?

[toc] | [prev] | [next] | [standalone]


#1355560 — Re: [RFC 1/9] mm/hugetlb: Make GENERAL_HUGETLB functions PGD implementation aware

FromAnshuman Khandual <khandual@linux.vnet.ibm.com>
Date2016-03-11 04:10 +0100
SubjectRe: [RFC 1/9] mm/hugetlb: Make GENERAL_HUGETLB functions PGD implementation aware
Message-ID<rblCG-8hC-15@gated-at.bofh.it>
In reply to#1354070
On 03/09/2016 05:40 PM, Anshuman Khandual wrote:
> Currently both the ARCH_WANT_GENERAL_HUGETLB functions 'huge_pte_alloc'
> and 'huge_pte_offset' dont take into account huge page implementation
> at the PGD level. With addition of PGD awareness into these functions,
> more architectures like POWER which also implements huge pages at PGD
> level (along with PMD level), can use ARCH_WANT_GENERAL_HUGETLB option.

Hugh/Mel/Naoya/Andrew,

	Thoughts/inputs/suggestions ? Does this change looks okay ?

[toc] | [prev] | [next] | [standalone]


#1357604 — Re: [RFC 1/9] mm/hugetlb: Make GENERAL_HUGETLB functions PGD implementation aware

FromAndrew Morton <akpm@linux-foundation.org>
Date2016-03-14 21:30 +0100
SubjectRe: [RFC 1/9] mm/hugetlb: Make GENERAL_HUGETLB functions PGD implementation aware
Message-ID<rcHhM-h8-11@gated-at.bofh.it>
In reply to#1355560
On Fri, 11 Mar 2016 08:31:55 +0530 Anshuman Khandual <khandual@linux.vnet.ibm.com> wrote:

> On 03/09/2016 05:40 PM, Anshuman Khandual wrote:
> > Currently both the ARCH_WANT_GENERAL_HUGETLB functions 'huge_pte_alloc'
> > and 'huge_pte_offset' dont take into account huge page implementation
> > at the PGD level. With addition of PGD awareness into these functions,
> > more architectures like POWER which also implements huge pages at PGD
> > level (along with PMD level), can use ARCH_WANT_GENERAL_HUGETLB option.
> 
> Hugh/Mel/Naoya/Andrew,
> 
> 	Thoughts/inputs/suggestions ? Does this change looks okay ?

Patches 1, 2 and 3 look OK to me.  Please include them in the powerpc
merge when the patchset is considered ready.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web