From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755243AbcDGFiN (ORCPT ); Thu, 7 Apr 2016 01:38:13 -0400 Received: from e28smtp01.in.ibm.com ([125.16.236.1]:52063 "EHLO e28smtp01.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752416AbcDGFiH (ORCPT ); Thu, 7 Apr 2016 01:38:07 -0400 X-IBM-Helo: d28relay03.in.ibm.com X-IBM-MailFrom: khandual@linux.vnet.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org From: Anshuman Khandual To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: hughd@google.com, kirill@shutemov.name, n-horiguchi@ah.jp.nec.com, akpm@linux-foundation.org, mgorman@techsingularity.net, dave.hansen@intel.com, aneesh.kumar@linux.vnet.ibm.com, mpe@ellerman.id.au Subject: [PATCH 06/10] powerpc/hugetlb: Split the function 'huge_pte_offset' Date: Thu, 7 Apr 2016 11:07:40 +0530 Message-Id: <1460007464-26726-7-git-send-email-khandual@linux.vnet.ibm.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1460007464-26726-1-git-send-email-khandual@linux.vnet.ibm.com> References: <1460007464-26726-1-git-send-email-khandual@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 16040705-4790-0000-0000-00000EB06687 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently the function 'huge_pte_offset' has just got one version for all possible configurations and platforms. This change splits that function into two versions, first one for ARCH_WANT_GENERAL_HUGETLB implementation and the other one for everything else. This change is again one of the prerequisites towards enabling ARCH_WANT_GENERAL_ HUGETLB config option on POWER platform. Signed-off-by: Anshuman Khandual --- 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 e453918..8fc6d23 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) +#ifndef CONFIG_ARCH_WANT_GENERAL_HUGETLB 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 /* CONFIG_ARCH_WANT_GENERAL_HUGETLB */ +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 /* !CONFIG_ARCH_WANT_GENERAL_HUGETLB */ #ifndef CONFIG_ARCH_WANT_GENERAL_HUGETLB static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp, -- 2.1.0