From: Nitin Gupta <nitin.m.gupta@oracle.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: "David S. Miller" <davem@davemloft.net>,
Nitin Gupta <nitin.m.gupta@oracle.com>,
Andrew Morton <akpm@linux-foundation.org>,
Steve Capper <steve.capper@arm.com>,
Hugh Dickins <hughd@google.com>,
Mike Kravetz <mike.kravetz@oracle.com>,
Punit Agrawal <punit.agrawal@arm.com>,
Ingo Molnar <mingo@kernel.org>,
sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] sparc64: Cleanup hugepage table walk functions
Date: Thu, 13 Jul 2017 14:53:25 -0700 [thread overview]
Message-ID: <1499982815-183450-4-git-send-email-nitin.m.gupta@oracle.com> (raw)
In-Reply-To: <1499982815-183450-1-git-send-email-nitin.m.gupta@oracle.com>
Flatten out nested code structure in huge_pte_offset()
and huge_pte_alloc().
Signed-off-by: Nitin Gupta <nitin.m.gupta@oracle.com>
---
arch/sparc/mm/hugetlbpage.c | 54 +++++++++++++++++----------------------------
1 file changed, 20 insertions(+), 34 deletions(-)
diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
index 7acb84d..bcd8cdb 100644
--- a/arch/sparc/mm/hugetlbpage.c
+++ b/arch/sparc/mm/hugetlbpage.c
@@ -266,27 +266,19 @@ pte_t *huge_pte_alloc(struct mm_struct *mm,
pgd_t *pgd;
pud_t *pud;
pmd_t *pmd;
- pte_t *pte = NULL;
pgd = pgd_offset(mm, addr);
pud = pud_alloc(mm, pgd, addr);
if (!pud)
return NULL;
-
if (sz >= PUD_SIZE)
- pte = (pte_t *)pud;
- else {
- pmd = pmd_alloc(mm, pud, addr);
- if (!pmd)
- return NULL;
-
- if (sz >= PMD_SIZE)
- pte = (pte_t *)pmd;
- else
- pte = pte_alloc_map(mm, pmd, addr);
- }
-
- return pte;
+ return (pte_t *)pud;
+ pmd = pmd_alloc(mm, pud, addr);
+ if (!pmd)
+ return NULL;
+ if (sz >= PMD_SIZE)
+ return (pte_t *)pmd;
+ return pte_alloc_map(mm, pmd, addr);
}
pte_t *huge_pte_offset(struct mm_struct *mm,
@@ -295,27 +287,21 @@ pte_t *huge_pte_offset(struct mm_struct *mm,
pgd_t *pgd;
pud_t *pud;
pmd_t *pmd;
- pte_t *pte = NULL;
pgd = pgd_offset(mm, addr);
- if (!pgd_none(*pgd)) {
- pud = pud_offset(pgd, addr);
- if (!pud_none(*pud)) {
- if (is_hugetlb_pud(*pud))
- pte = (pte_t *)pud;
- else {
- pmd = pmd_offset(pud, addr);
- if (!pmd_none(*pmd)) {
- if (is_hugetlb_pmd(*pmd))
- pte = (pte_t *)pmd;
- else
- pte = pte_offset_map(pmd, addr);
- }
- }
- }
- }
-
- return pte;
+ if (pgd_none(*pgd))
+ return NULL;
+ pud = pud_offset(pgd, addr);
+ if (pud_none(*pud))
+ return NULL;
+ if (is_hugetlb_pud(*pud))
+ return (pte_t *)pud;
+ pmd = pmd_offset(pud, addr);
+ if (pmd_none(*pmd))
+ return NULL;
+ if (is_hugetlb_pmd(*pmd))
+ return (pte_t *)pmd;
+ return pte_offset_map(pmd, addr);
}
void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
--
2.9.2
prev parent reply other threads:[~2017-07-13 21:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1499982815-183450-1-git-send-email-nitin.m.gupta@oracle.com>
2017-07-13 21:53 ` [PATCH 1/3] sparc64: Support huge PUD case in get_user_pages Nitin Gupta
2017-07-13 21:53 ` [PATCH 2/3] sparc64: Add 16GB hugepage support Nitin Gupta
2017-07-20 20:04 ` David Miller
2017-07-26 18:35 ` Nitin Gupta
2017-07-26 20:10 ` David Miller
2017-07-13 21:53 ` Nitin Gupta [this message]
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=1499982815-183450-4-git-send-email-nitin.m.gupta@oracle.com \
--to=nitin.m.gupta@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mike.kravetz@oracle.com \
--cc=mingo@kernel.org \
--cc=punit.agrawal@arm.com \
--cc=sparclinux@vger.kernel.org \
--cc=steve.capper@arm.com \
/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
all inboxes | Powered by JetHome®