All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Nanyong Sun <sunnanyong@huawei.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>,
	palmer@dabbelt.com, aou@eecs.berkeley.edu,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	palmerdabbelt@google.com, atish.patra@wdc.com,
	wangkefeng.wang@huawei.com, Jisheng Zhang <jszhang@kernel.org>
Subject: Re: [PATCH -next 4/4] riscv: mm: add THP support on 64-bit
Date: Tue, 25 May 2021 14:14:45 +0200	[thread overview]
Message-ID: <CAMuHMdWxQO1ik_-On3qZMN9+r8V8YMgfg2EArxiMDvoHQRo=+g@mail.gmail.com> (raw)
In-Reply-To: <20210430082850.462609-5-sunnanyong@huawei.com>

Hi Nanyong,

On Fri, Apr 30, 2021 at 9:58 AM Nanyong Sun <sunnanyong@huawei.com> wrote:
> Bring Transparent HugePage support to riscv. A
> transparent huge page is always represented as a pmd.
>
> Signed-off-by: Nanyong Sun <sunnanyong@huawei.com>

Thanks for your patch, which is now commit e88b333142e4aba7 ("riscv:
mm: add THP support on 64-bit") in riscv/for-next.

> --- a/arch/riscv/include/asm/pgtable.h
> +++ b/arch/riscv/include/asm/pgtable.h

> @@ -438,6 +459,141 @@ static inline int ptep_clear_flush_young(struct vm_area_struct *vma,
>         return ptep_test_and_clear_young(vma, address, ptep);
>  }
>
> +/*
> + * THP functions
> + */
> +static inline pmd_t pte_pmd(pte_t pte)
> +{
> +       return __pmd(pte_val(pte));
> +}
> +
> +static inline pmd_t pmd_mkhuge(pmd_t pmd)
> +{
> +       return pmd;
> +}
> +
> +static inline pmd_t pmd_mkinvalid(pmd_t pmd)
> +{
> +       return __pmd(pmd_val(pmd) & ~(_PAGE_PRESENT|_PAGE_PROT_NONE));
> +}
> +
> +#define __pmd_to_phys(pmd)  (pmd_val(pmd) >> _PAGE_PFN_SHIFT << PAGE_SHIFT)
> +
> +static inline unsigned long pmd_pfn(pmd_t pmd)s
> +{
> +       return ((__pmd_to_phys(pmd) & PMD_MASK) >> PAGE_SHIFT);
> +}
> +
> +static inline pmd_t mk_pmd(struct page *page, pgprot_t prot)
> +{
> +       return pfn_pmd(page_to_pfn(page), prot);
> +}
> +
> +static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
> +{
> +       return pte_pmd(pte_modify(pmd_pte(pmd), newprot));
> +}
> +
> +#define pmd_write pmd_write
> +static inline int pmd_write(pmd_t pmd)
> +{
> +       return pte_write(pmd_pte(pmd));
> +}
> +
> +static inline int pmd_dirty(pmd_t pmd)
> +{
> +       return pte_dirty(pmd_pte(pmd));
> +}
> +
> +static inline int pmd_young(pmd_t pmd)
> +{
> +       return pte_young(pmd_pte(pmd));
> +}
> +
> +static inline pmd_t pmd_mkold(pmd_t pmd)
> +{
> +       return pte_pmd(pte_mkold(pmd_pte(pmd)));
> +}
> +
> +static inline pmd_t pmd_mkyoung(pmd_t pmd)
> +{
> +       return pte_pmd(pte_mkyoung(pmd_pte(pmd)));
> +}
> +
> +static inline pmd_t pmd_mkwrite(pmd_t pmd)
> +{
> +       return pte_pmd(pte_mkwrite(pmd_pte(pmd)));
> +}
> +
> +static inline pmd_t pmd_wrprotect(pmd_t pmd)
> +{
> +       return pte_pmd(pte_wrprotect(pmd_pte(pmd)));
> +}
> +
> +static inline pmd_t pmd_mkclean(pmd_t pmd)
> +{
> +       return pte_pmd(pte_mkclean(pmd_pte(pmd)));
> +}
> +
> +static inline pmd_t pmd_mkdirty(pmd_t pmd)
> +{
> +       return pte_pmd(pte_mkdirty(pmd_pte(pmd)));
> +}
> +
> +static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr,
> +                               pmd_t *pmdp, pmd_t pmd)
> +{
> +       return set_pte_at(mm, addr, (pte_t *)pmdp, pmd_pte(pmd));
> +}

This conflicts with the existing definition recently added in commit
756a8896b6166bba ("riscv: mremap speedup - enable HAVE_MOVE_PUD and
HAVE_MOVE_PMD"):

    arch/riscv/include/asm/pgtable.h:579:20: error: redefinition of ‘set_pmd_at’
      579 | static inline void set_pmd_at(struct mm_struct *mm,
unsigned long addr,
          |                    ^~~~~~~~~~
    arch/riscv/include/asm/pgtable.h:420:20: note: previous definition
of ‘set_pmd_at’ was here
      420 | static inline void set_pmd_at(struct mm_struct *mm,
unsigned long addr,
          |                    ^~~~~~~~~~

> +
> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
> +static inline int pmd_trans_huge(pmd_t pmd)
> +{
> +       return pmd_leaf(pmd);
> +}
> +
> +#define __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS
> +static inline int pmdp_set_access_flags(struct vm_area_struct *vma,
> +                                       unsigned long address, pmd_t *pmdp,
> +                                       pmd_t entry, int dirty)
> +{
> +       return ptep_set_access_flags(vma, address, (pte_t *)pmdp, pmd_pte(entry), dirty);
> +}
> +
> +#define __HAVE_ARCH_PMDP_TEST_AND_CLEAR_YOUNG
> +static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma,
> +                                       unsigned long address, pmd_t *pmdp)
> +{
> +       return ptep_test_and_clear_young(vma, address, (pte_t *)pmdp);
> +}
> +
> +#define __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR
> +static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
> +                                       unsigned long address, pmd_t *pmdp)
> +{
> +       return pte_pmd(ptep_get_and_clear(mm, address, (pte_t *)pmdp));
> +}
> +
> +#define __HAVE_ARCH_PMDP_SET_WRPROTECT
> +static inline void pmdp_set_wrprotect(struct mm_struct *mm,
> +                                       unsigned long address, pmd_t *pmdp)
> +{
> +       ptep_set_wrprotect(mm, address, (pte_t *)pmdp);
> +}
> +
> +#define pmdp_establish pmdp_establish
> +static inline pmd_t pmdp_establish(struct vm_area_struct *vma,
> +                               unsigned long address, pmd_t *pmdp, pmd_t pmd)
> +{
> +       return __pmd(atomic_long_xchg((atomic_long_t *)pmdp, pmd_val(pmd)));
> +}
> +
> +#define __HAVE_ARCH_FLUSH_PMD_TLB_RANGE
> +void flush_pmd_tlb_range(struct vm_area_struct *vma, unsigned long start,
> +                       unsigned long end);
> +
> +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
> +
>  /*
>   * Encode and decode a swap entry
>   *

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

WARNING: multiple messages have this Message-ID (diff)
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Nanyong Sun <sunnanyong@huawei.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>,
	palmer@dabbelt.com, aou@eecs.berkeley.edu,
	 linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	 palmerdabbelt@google.com, atish.patra@wdc.com,
	wangkefeng.wang@huawei.com,  Jisheng Zhang <jszhang@kernel.org>
Subject: Re: [PATCH -next 4/4] riscv: mm: add THP support on 64-bit
Date: Tue, 25 May 2021 14:14:45 +0200	[thread overview]
Message-ID: <CAMuHMdWxQO1ik_-On3qZMN9+r8V8YMgfg2EArxiMDvoHQRo=+g@mail.gmail.com> (raw)
In-Reply-To: <20210430082850.462609-5-sunnanyong@huawei.com>

Hi Nanyong,

On Fri, Apr 30, 2021 at 9:58 AM Nanyong Sun <sunnanyong@huawei.com> wrote:
> Bring Transparent HugePage support to riscv. A
> transparent huge page is always represented as a pmd.
>
> Signed-off-by: Nanyong Sun <sunnanyong@huawei.com>

Thanks for your patch, which is now commit e88b333142e4aba7 ("riscv:
mm: add THP support on 64-bit") in riscv/for-next.

> --- a/arch/riscv/include/asm/pgtable.h
> +++ b/arch/riscv/include/asm/pgtable.h

> @@ -438,6 +459,141 @@ static inline int ptep_clear_flush_young(struct vm_area_struct *vma,
>         return ptep_test_and_clear_young(vma, address, ptep);
>  }
>
> +/*
> + * THP functions
> + */
> +static inline pmd_t pte_pmd(pte_t pte)
> +{
> +       return __pmd(pte_val(pte));
> +}
> +
> +static inline pmd_t pmd_mkhuge(pmd_t pmd)
> +{
> +       return pmd;
> +}
> +
> +static inline pmd_t pmd_mkinvalid(pmd_t pmd)
> +{
> +       return __pmd(pmd_val(pmd) & ~(_PAGE_PRESENT|_PAGE_PROT_NONE));
> +}
> +
> +#define __pmd_to_phys(pmd)  (pmd_val(pmd) >> _PAGE_PFN_SHIFT << PAGE_SHIFT)
> +
> +static inline unsigned long pmd_pfn(pmd_t pmd)s
> +{
> +       return ((__pmd_to_phys(pmd) & PMD_MASK) >> PAGE_SHIFT);
> +}
> +
> +static inline pmd_t mk_pmd(struct page *page, pgprot_t prot)
> +{
> +       return pfn_pmd(page_to_pfn(page), prot);
> +}
> +
> +static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
> +{
> +       return pte_pmd(pte_modify(pmd_pte(pmd), newprot));
> +}
> +
> +#define pmd_write pmd_write
> +static inline int pmd_write(pmd_t pmd)
> +{
> +       return pte_write(pmd_pte(pmd));
> +}
> +
> +static inline int pmd_dirty(pmd_t pmd)
> +{
> +       return pte_dirty(pmd_pte(pmd));
> +}
> +
> +static inline int pmd_young(pmd_t pmd)
> +{
> +       return pte_young(pmd_pte(pmd));
> +}
> +
> +static inline pmd_t pmd_mkold(pmd_t pmd)
> +{
> +       return pte_pmd(pte_mkold(pmd_pte(pmd)));
> +}
> +
> +static inline pmd_t pmd_mkyoung(pmd_t pmd)
> +{
> +       return pte_pmd(pte_mkyoung(pmd_pte(pmd)));
> +}
> +
> +static inline pmd_t pmd_mkwrite(pmd_t pmd)
> +{
> +       return pte_pmd(pte_mkwrite(pmd_pte(pmd)));
> +}
> +
> +static inline pmd_t pmd_wrprotect(pmd_t pmd)
> +{
> +       return pte_pmd(pte_wrprotect(pmd_pte(pmd)));
> +}
> +
> +static inline pmd_t pmd_mkclean(pmd_t pmd)
> +{
> +       return pte_pmd(pte_mkclean(pmd_pte(pmd)));
> +}
> +
> +static inline pmd_t pmd_mkdirty(pmd_t pmd)
> +{
> +       return pte_pmd(pte_mkdirty(pmd_pte(pmd)));
> +}
> +
> +static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr,
> +                               pmd_t *pmdp, pmd_t pmd)
> +{
> +       return set_pte_at(mm, addr, (pte_t *)pmdp, pmd_pte(pmd));
> +}

This conflicts with the existing definition recently added in commit
756a8896b6166bba ("riscv: mremap speedup - enable HAVE_MOVE_PUD and
HAVE_MOVE_PMD"):

    arch/riscv/include/asm/pgtable.h:579:20: error: redefinition of ‘set_pmd_at’
      579 | static inline void set_pmd_at(struct mm_struct *mm,
unsigned long addr,
          |                    ^~~~~~~~~~
    arch/riscv/include/asm/pgtable.h:420:20: note: previous definition
of ‘set_pmd_at’ was here
      420 | static inline void set_pmd_at(struct mm_struct *mm,
unsigned long addr,
          |                    ^~~~~~~~~~

> +
> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
> +static inline int pmd_trans_huge(pmd_t pmd)
> +{
> +       return pmd_leaf(pmd);
> +}
> +
> +#define __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS
> +static inline int pmdp_set_access_flags(struct vm_area_struct *vma,
> +                                       unsigned long address, pmd_t *pmdp,
> +                                       pmd_t entry, int dirty)
> +{
> +       return ptep_set_access_flags(vma, address, (pte_t *)pmdp, pmd_pte(entry), dirty);
> +}
> +
> +#define __HAVE_ARCH_PMDP_TEST_AND_CLEAR_YOUNG
> +static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma,
> +                                       unsigned long address, pmd_t *pmdp)
> +{
> +       return ptep_test_and_clear_young(vma, address, (pte_t *)pmdp);
> +}
> +
> +#define __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR
> +static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
> +                                       unsigned long address, pmd_t *pmdp)
> +{
> +       return pte_pmd(ptep_get_and_clear(mm, address, (pte_t *)pmdp));
> +}
> +
> +#define __HAVE_ARCH_PMDP_SET_WRPROTECT
> +static inline void pmdp_set_wrprotect(struct mm_struct *mm,
> +                                       unsigned long address, pmd_t *pmdp)
> +{
> +       ptep_set_wrprotect(mm, address, (pte_t *)pmdp);
> +}
> +
> +#define pmdp_establish pmdp_establish
> +static inline pmd_t pmdp_establish(struct vm_area_struct *vma,
> +                               unsigned long address, pmd_t *pmdp, pmd_t pmd)
> +{
> +       return __pmd(atomic_long_xchg((atomic_long_t *)pmdp, pmd_val(pmd)));
> +}
> +
> +#define __HAVE_ARCH_FLUSH_PMD_TLB_RANGE
> +void flush_pmd_tlb_range(struct vm_area_struct *vma, unsigned long start,
> +                       unsigned long end);
> +
> +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
> +
>  /*
>   * Encode and decode a swap entry
>   *

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2021-05-25 12:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-30  8:28 [PATCH -next 0/4] THP supprt for RISCV Nanyong Sun
2021-04-30  8:28 ` Nanyong Sun
2021-04-30  8:28 ` [PATCH -next 1/4] riscv: mm: add _PAGE_LEAF macro Nanyong Sun
2021-04-30  8:28   ` Nanyong Sun
2021-04-30  8:28 ` [PATCH -next 2/4] riscv: mm: make pmd_bad() check leaf condition Nanyong Sun
2021-04-30  8:28   ` Nanyong Sun
2021-04-30  8:28 ` [PATCH -next 3/4] riscv: mm: add param stride for __sbi_tlb_flush_range Nanyong Sun
2021-04-30  8:28   ` Nanyong Sun
2021-04-30  8:28 ` [PATCH -next 4/4] riscv: mm: add THP support on 64-bit Nanyong Sun
2021-04-30  8:28   ` Nanyong Sun
2021-05-25 12:14   ` Geert Uytterhoeven [this message]
2021-05-25 12:14     ` Geert Uytterhoeven
2021-05-26  5:54     ` Palmer Dabbelt
2021-05-26  5:54       ` Palmer Dabbelt
2021-05-06  7:21 ` [PATCH -next 0/4] THP supprt for RISCV Palmer Dabbelt
2021-05-06  7:21   ` Palmer Dabbelt
2021-05-22 18:55 ` Palmer Dabbelt
2021-05-22 18:55   ` Palmer Dabbelt

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='CAMuHMdWxQO1ik_-On3qZMN9+r8V8YMgfg2EArxiMDvoHQRo=+g@mail.gmail.com' \
    --to=geert@linux-m68k.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=atish.patra@wdc.com \
    --cc=jszhang@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=palmerdabbelt@google.com \
    --cc=paul.walmsley@sifive.com \
    --cc=sunnanyong@huawei.com \
    --cc=wangkefeng.wang@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.