Re: [PATCH 3/5] m68k,mm: Use table allocator for pgtables

From: Peter Zijlstra
Date: Wed Jan 29 2020 - 07:25:02 EST


On Wed, Jan 29, 2020 at 12:11:50PM +0000, Will Deacon wrote:
> On Wed, Jan 29, 2020 at 11:39:44AM +0100, Peter Zijlstra wrote:

> > --- a/arch/m68k/include/asm/motorola_pgalloc.h
> > +++ b/arch/m68k/include/asm/motorola_pgalloc.h
> > @@ -10,60 +10,28 @@ extern int free_pointer_table(pmd_t *);
> >
> > static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
> > {
> > - pte_t *pte;
> > -
> > - pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
> > - if (pte) {
> > - __flush_page_to_ram(pte);
> > - flush_tlb_kernel_page(pte);
> > - nocache_page(pte);
> > - }
> > -
> > - return pte;
> > + return (pte_t *)get_pointer_table();
>
> Weirdly, get_pointer_table() seems to elide the __flush_page_to_ram()
> call, so you're missing that for ptes with this change. I think it's
> probably needed for the higher levels too (and kernel_page_table()
> does it for example) so I'd be inclined to add it unconditionally
> rather than predicate it on the allocation type introduced by your later
> patch.

The next patch adds that unconditionally to the table allocator. The
only thing conditional on the type is the PG_PageTable and NR_PAGETABLES
accounting crud.

> > --- a/arch/m68k/include/asm/page.h
> > +++ b/arch/m68k/include/asm/page.h
> > @@ -30,7 +30,7 @@ typedef struct { unsigned long pmd; } pm
> > typedef struct { unsigned long pte; } pte_t;
> > typedef struct { unsigned long pgd; } pgd_t;
> > typedef struct { unsigned long pgprot; } pgprot_t;
> > -typedef struct page *pgtable_t;
> > +typedef pte_t *pgtable_t;
>
> Urgh, this is a big (cross-arch) mess that we should fix later.

Yes, I ran into this when I did those MMU-gather fixes as well. For this
patch I cribbed what s390 already does.