From: Bob Liu <lliubbo@gmail.com>
To: akpm@linux-foundation.org
Cc: aarcange@redhat.com, xiaoguangrong@linux.vnet.ibm.com,
hughd@google.com, rientjes@google.com,
kirill.shutemov@linux.intel.com, Bob Liu <lliubbo@gmail.com>,
linux-mm@kvack.org
Subject: Re: [PATCH 2/4] thp: introduce hugepage_get_pmd()
Date: Thu, 18 Oct 2012 18:20:42 +0800 [thread overview]
Message-ID: <CAA_GA1epiwyNHWRW1tbO9bnhYZXsTJ2Fd-806UU6s7X=A4HuVw@mail.gmail.com> (raw)
In-Reply-To: <1350555140-11030-2-git-send-email-lliubbo@gmail.com>
On Thu, Oct 18, 2012 at 6:12 PM, Bob Liu <lliubbo@gmail.com> wrote:
> Introduce hugepage_get_pmd() to simple code.
>
> Signed-off-by: Bob Liu <lliubbo@gmail.com>
> ---
> mm/huge_memory.c | 68 ++++++++++++++++++++++--------------------------------
> 1 file changed, 27 insertions(+), 41 deletions(-)
>
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 462d6ea..e575b29 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -1115,6 +1115,25 @@ int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
> return ret;
> }
>
> +static pmd_t *hugepage_get_pmd(struct mm_struct *mm, unsigned long address)
> +{
> + pgd_t *pgd;
> + pud_t *pud;
> + pmd_t *pmd = NULL;
> +
> + pgd = pgd_offset(mm, address);
> + if (!pgd_present(*pgd))
> + goto out;
> +
> + pud = pud_offset(pgd, address);
> + if (!pud_present(*pud))
> + goto out;
> +
> + pmd = pmd_offset(pud, address);
> +out:
> + return pmd;
> +}
> +
> /*
> * Returns 1 if a given pmd maps a stable (not under splitting) thp.
> * Returns -1 if it maps a thp under splitting. Returns 0 otherwise.
> @@ -1145,22 +1164,14 @@ pmd_t *page_check_address_pmd(struct page *page,
> unsigned long address,
> enum page_check_address_pmd_flag flag)
> {
> - pgd_t *pgd;
> - pud_t *pud;
> pmd_t *pmd, *ret = NULL;
>
> if (address & ~HPAGE_PMD_MASK)
> goto out;
>
> - pgd = pgd_offset(mm, address);
> - if (!pgd_present(*pgd))
> - goto out;
> -
> - pud = pud_offset(pgd, address);
> - if (!pud_present(*pud))
> + pmd = hugepage_get_pmd(mm, address);
> + if (!pmd)
> goto out;
> -
> - pmd = pmd_offset(pud, address);
> if (pmd_none(*pmd))
> goto out;
> if (pmd_page(*pmd) != page)
> @@ -1908,8 +1919,6 @@ static void collapse_huge_page(struct mm_struct *mm,
> struct vm_area_struct *vma,
> int node)
> {
> - pgd_t *pgd;
> - pud_t *pud;
> pmd_t *pmd, _pmd;
> pte_t *pte;
> pgtable_t pgtable;
> @@ -1955,16 +1964,9 @@ static void collapse_huge_page(struct mm_struct *mm,
> goto out;
> VM_BUG_ON(vma->vm_flags & VM_NO_THP);
>
> - pgd = pgd_offset(mm, address);
> - if (!pgd_present(*pgd))
> + pmd = hugepage_get_pmd(mm, address);
> + if (!pmd)
> goto out;
> -
> - pud = pud_offset(pgd, address);
> - if (!pud_present(*pud))
> - goto out;
> -
> - pmd = pmd_offset(pud, address);
> - /* pmd can't go away or become huge under us */
> if (!pmd_present(*pmd) || pmd_trans_huge(*pmd))
> goto out;
>
> @@ -2048,8 +2050,6 @@ static int khugepaged_scan_pmd(struct mm_struct *mm,
> unsigned long address,
> struct page **hpage)
> {
> - pgd_t *pgd;
> - pud_t *pud;
> pmd_t *pmd;
> pte_t *pte, *_pte;
> int ret = 0, referenced = 0, none = 0;
> @@ -2060,15 +2060,9 @@ static int khugepaged_scan_pmd(struct mm_struct *mm,
>
> VM_BUG_ON(address & ~HPAGE_PMD_MASK);
>
> - pgd = pgd_offset(mm, address);
> - if (!pgd_present(*pgd))
> - goto out;
> -
> - pud = pud_offset(pgd, address);
> - if (!pud_present(*pud))
> + pmd = hugepage_get_pmd(mm, address);
> + if (!pmd)
> goto out;
> -
> - pmd = pmd_offset(pud, address);
> if (!pmd_present(*pmd) || pmd_trans_huge(*pmd))
> goto out;
>
> @@ -2363,21 +2357,13 @@ void __split_huge_page_pmd(struct mm_struct *mm, pmd_t *pmd)
> static void split_huge_page_address(struct mm_struct *mm,
> unsigned long address)
> {
> - pgd_t *pgd;
> - pud_t *pud;
> pmd_t *pmd;
>
> VM_BUG_ON(!(address & ~HPAGE_PMD_MASK));
>
> - pgd = pgd_offset(mm, address);
> - if (!pgd_present(*pgd))
> - return;
> -
> - pud = pud_offset(pgd, address);
> - if (!pud_present(*pud))
> + pmd = hugepage_get_pmd(mm, address);
> + if (!pmd)
> return;
> -
> - pmd = pmd_offset(pud, address);
> if (!pmd_present(*pmd))
> return;
> /*
> --
> 1.7.9.5
>
>
--
Regards,
--Bob
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2012-10-18 10:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1350555140-11030-1-git-send-email-lliubbo@gmail.com>
2012-10-18 10:20 ` [PATCH 1/4] thp: clean up __collapse_huge_page_isolate Bob Liu
2012-10-19 1:07 ` Ni zhan Chen
[not found] ` <1350555140-11030-2-git-send-email-lliubbo@gmail.com>
2012-10-18 10:20 ` Bob Liu [this message]
[not found] ` <alpine.DEB.2.00.1210181314380.26994@chino.kir.corp.google.com>
2012-10-19 3:00 ` [PATCH 2/4] thp: introduce hugepage_get_pmd() Bob Liu
[not found] ` <1350555140-11030-3-git-send-email-lliubbo@gmail.com>
2012-10-18 10:21 ` [PATCH 3/4] thp: introduce hugepage_vma_check() Bob Liu
[not found] ` <1350555140-11030-4-git-send-email-lliubbo@gmail.com>
2012-10-18 10:21 ` [PATCH 4/4] thp: cleanup: introduce mk_huge_pmd() Bob Liu
[not found] ` <alpine.DEB.2.00.1210181311390.26994@chino.kir.corp.google.com>
2012-10-19 2:51 ` [PATCH 1/4] thp: clean up __collapse_huge_page_isolate Bob Liu
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='CAA_GA1epiwyNHWRW1tbO9bnhYZXsTJ2Fd-806UU6s7X=A4HuVw@mail.gmail.com' \
--to=lliubbo@gmail.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-mm@kvack.org \
--cc=rientjes@google.com \
--cc=xiaoguangrong@linux.vnet.ibm.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