Re: [PATCH 0/5] Rewrite Motorola MMU page-table layout

From: Peter Zijlstra
Date: Fri Jan 31 2020 - 05:22:46 EST


On Fri, Jan 31, 2020 at 09:38:13AM +0000, Will Deacon wrote:

> > This series breaks compilation for the ColdFire (with MMU) variant of
> > the m68k family:

That's like the same I had reported by the build robots for sun3, which
I fixed by frobbing pgtable_t. That said, this is probably a more
consistent change.

One note below:


> -static inline struct page *pte_alloc_one(struct mm_struct *mm)
> +static inline pgtable_t pte_alloc_one(struct mm_struct *mm)
> {
> struct page *page = alloc_pages(GFP_DMA, 0);
> pte_t *pte;
> @@ -54,20 +55,19 @@ static inline struct page *pte_alloc_one(struct mm_struct *mm)
> return NULL;
> }
>
> - pte = kmap(page);
> - if (pte) {
> - clear_page(pte);
> - __flush_page_to_ram(pte);
> - flush_tlb_kernel_page(pte);
> - nocache_page(pte);
> - }
> - kunmap(page);
> + pte = page_address(page);
> + clear_page(pte);
> + __flush_page_to_ram(pte);
> + flush_tlb_kernel_page(pte);
> + nocache_page(pte);

See how it does the nocache dance ^

>
> - return page;
> + return pte;
> }
>
> -static inline void pte_free(struct mm_struct *mm, struct page *page)
> +static inline void pte_free(struct mm_struct *mm, pgtable_t pgtable)
> {
> + struct page *page = virt_to_page(pgtable);
> +

but never sets it cached again!

> pgtable_pte_page_dtor(page);
> __free_page(page);
> }

Also, the alloc_one_kernel() also suspicioudly doesn't do the nocache
thing.

So either, alloc_one() shouldn't either, or it's all buggered.