Re: [PATCH v2 30/34] sh: Convert pte_free_tlb() to use ptdescs

Vishal Moola
2023-05-15T19:12:16Z

On Sat, May 6, 2023 at 4:35 AM John Paul Adrian Glaubitz
<glaubitz@physik.fu-berlin.de> wrote:
>
> Hi Vishal!
>
> On Mon, 2023-05-01 at 12:28 -0700, Vishal Moola (Oracle) wrote:
> > Part of the conversions to replace pgtable constructor/destructors with
> > ptdesc equivalents. Also cleans up some spacing issues.
> >
> > Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
> > ---
> > arch/sh/include/asm/pgalloc.h | 9 +++++----
> > 1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/sh/include/asm/pgalloc.h b/arch/sh/include/asm/pgalloc.h
> > index a9e98233c4d4..ce2ba99dbd84 100644
> > --- a/arch/sh/include/asm/pgalloc.h
> > +++ b/arch/sh/include/asm/pgalloc.h
> > @@ -2,6 +2,7 @@
> > #ifndef __ASM_SH_PGALLOC_H
> > #define __ASM_SH_PGALLOC_H
> >
> > +#include <linux/mm.h>
> > #include <asm/page.h>
> >
> > #define __HAVE_ARCH_PMD_ALLOC_ONE
> > @@ -31,10 +32,10 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
> > set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
> > }
> >
> > -#define __pte_free_tlb(tlb,pte,addr) \
> > -do { \
> > - pgtable_pte_page_dtor(pte); \
> > - tlb_remove_page((tlb), (pte)); \
> > +#define __pte_free_tlb(tlb, pte, addr) \
> > +do { \
> > + ptdesc_pte_dtor(page_ptdesc(pte)); \
> > + tlb_remove_page_ptdesc((tlb), (page_ptdesc(pte))); \
> > } while (0)
> >
> > #endif /* __ASM_SH_PGALLOC_H */
>
> Looking at the patch which introduces tlb_remove_page_ptdesc() [1], it seems that
> tlb_remove_page_ptdesc() already calls tlb_remove_page() with ptdesc_page(pt), so
> I'm not sure whether the above tlb_remove_page_ptdesc((tlb), (page_ptdesc(pte)))
> is correct.
>
> Shouldn't it just be tlb_remove_page_ptdesc((tlb), (pte))?

As of this patchset all implementations of __pte_free_tlb() take in a
struct page. Eventually we'll want it to be tlb_remove_page_ptdesc(tlb, pte),
but for now the cast is necessary here.