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


Groups > linux.kernel > #1354070

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

From Anshuman Khandual <khandual@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject [RFC 1/9] mm/hugetlb: Make GENERAL_HUGETLB functions PGD implementation aware
Date 2016-03-09 13:20 +0100
Message-ID <raLfP-7Ms-3@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[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

csiph-web