Re: [PATCHv2 2/2] xtensa: use buddy allocator for PTE table

From: Kirill A. Shutemov
Date: Mon Oct 14 2013 - 11:44:13 EST


Max Filippov wrote:
> On Mon, Oct 14, 2013 at 6:32 PM, Kirill A. Shutemov
> <kirill.shutemov@xxxxxxxxxxxxxxx> wrote:
> > At the moment xtensa uses slab allocator for PTE table. It doesn't work
> > with enabled split page table lock: slab uses page->slab_cache and
> > page->first_page for its pages. These fields share stroage with
> > page->ptl.
> >
> > Signed-off-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>
> > Cc: Chris Zankel <chris@xxxxxxxxxx>
> > Cc: Max Filippov <jcmvbkbc@xxxxxxxxx>
> > ---
> > v2:
> > - add missed return in pte_alloc_one_kernel;
> >
> > arch/xtensa/include/asm/pgalloc.h | 20 ++++++++++++--------
> > arch/xtensa/include/asm/pgtable.h | 3 +--
> > arch/xtensa/mm/mmu.c | 20 --------------------
> > 3 files changed, 13 insertions(+), 30 deletions(-)
> >
> > diff --git a/arch/xtensa/include/asm/pgalloc.h b/arch/xtensa/include/asm/pgalloc.h
> > index b8774f1e21..8507b32d6e 100644
> > --- a/arch/xtensa/include/asm/pgalloc.h
> > +++ b/arch/xtensa/include/asm/pgalloc.h
> > @@ -38,14 +38,18 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
> > free_page((unsigned long)pgd);
> > }
> >
> > -/* Use a slab cache for the pte pages (see also sparc64 implementation) */
> > -
> > -extern struct kmem_cache *pgtable_cache;
> > -
> > static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
> > unsigned long address)
> > {
> > - return kmem_cache_alloc(pgtable_cache, GFP_KERNEL|__GFP_REPEAT);
> > + pte_t *ptep;
> > + int i;
> > +
> > + ptep = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
> > + if (!ptep)
> > + return NULL;
> > + for (i = 0; i < 1024; i++, ptep++)
> > + pte_clear(NULL, 0, ptep);
> > + return ptep;
>
> You're returning modified ptep, not the allocated one.

Erghh.. Stupid me.

Corrected patch below.