Re: [PATCH 4/4] thp: cleanup: introduce mk_huge_pmd()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 18, 2012 at 6:12 PM, Bob Liu <lliubbo@xxxxxxxxx> wrote:
> Introduce mk_huge_pmd() to simple code
>
> Signed-off-by: Bob Liu <lliubbo@xxxxxxxxx>
> ---
>  mm/huge_memory.c |   21 ++++++++++++---------
>  1 file changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 3588fec..9fd1312 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -605,6 +605,15 @@ static inline pmd_t maybe_pmd_mkwrite(pmd_t pmd, struct vm_area_struct *vma)
>         return pmd;
>  }
>
> +static inline pmd_t mk_huge_pmd(struct page *page, struct vm_area_struct *vma)
> +{
> +       pmd_t entry;
> +       entry = mk_pmd(page, vma->vm_page_prot);
> +       entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma);
> +       entry = pmd_mkhuge(entry);
> +       return entry;
> +}
> +
>  static int __do_huge_pmd_anonymous_page(struct mm_struct *mm,
>                                         struct vm_area_struct *vma,
>                                         unsigned long haddr, pmd_t *pmd,
> @@ -628,9 +637,7 @@ static int __do_huge_pmd_anonymous_page(struct mm_struct *mm,
>                 pte_free(mm, pgtable);
>         } else {
>                 pmd_t entry;
> -               entry = mk_pmd(page, vma->vm_page_prot);
> -               entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma);
> -               entry = pmd_mkhuge(entry);
> +               entry = mk_huge_pmd(page, vma);
>                 /*
>                  * The spinlocking to take the lru_lock inside
>                  * page_add_new_anon_rmap() acts as a full memory
> @@ -950,9 +957,7 @@ int do_huge_pmd_wp_page(struct mm_struct *mm, struct vm_area_struct *vma,
>         } else {
>                 pmd_t entry;
>                 VM_BUG_ON(!PageHead(page));
> -               entry = mk_pmd(new_page, vma->vm_page_prot);
> -               entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma);
> -               entry = pmd_mkhuge(entry);
> +               entry = mk_huge_pmd(new_page, vma);
>                 pmdp_clear_flush(vma, haddr, pmd);
>                 page_add_new_anon_rmap(new_page, vma, haddr);
>                 set_pmd_at(mm, haddr, pmd, entry);
> @@ -2019,9 +2024,7 @@ static void collapse_huge_page(struct mm_struct *mm,
>         __SetPageUptodate(new_page);
>         pgtable = pmd_pgtable(_pmd);
>
> -       _pmd = mk_pmd(new_page, vma->vm_page_prot);
> -       _pmd = maybe_pmd_mkwrite(pmd_mkdirty(_pmd), vma);
> -       _pmd = pmd_mkhuge(_pmd);
> +       _pmd = mk_huge_pmd(new_page, vma);
>
>         /*
>          * spin_lock() below is not the equivalent of smp_wmb(), so
> --
> 1.7.9.5
>
>



-- 
Regards,
--Bob

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]