Skip to content

Commit f820e28

Browse files
kiryltorvalds
authored andcommitted
xtensa: use buddy allocator for PTE table
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@linux.intel.com> Cc: Chris Zankel <chris@zankel.net> Acked-by: Max Filippov <jcmvbkbc@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 01058e7 commit f820e28

3 files changed

Lines changed: 13 additions & 30 deletions

File tree

‎arch/xtensa/include/asm/pgalloc.h‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,18 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
3838
free_page((unsigned long)pgd);
3939
}
4040

41-
/* Use a slab cache for the pte pages (see also sparc64 implementation) */
42-
43-
extern struct kmem_cache *pgtable_cache;
44-
4541
static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
4642
unsigned long address)
4743
{
48-
return kmem_cache_alloc(pgtable_cache, GFP_KERNEL|__GFP_REPEAT);
44+
pte_t *ptep;
45+
int i;
46+
47+
ptep = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
48+
if (!ptep)
49+
return NULL;
50+
for (i = 0; i < 1024; i++)
51+
pte_clear(NULL, 0, ptep + i);
52+
return ptep;
4953
}
5054

5155
static inline pgtable_t pte_alloc_one(struct mm_struct *mm,
@@ -59,21 +63,21 @@ static inline pgtable_t pte_alloc_one(struct mm_struct *mm,
5963
return NULL;
6064
page = virt_to_page(pte);
6165
if (!pgtable_page_ctor(page)) {
62-
kmem_cache_free(pgtable_cache, pte);
66+
__free_page(page);
6367
return NULL;
6468
}
6569
return page;
6670
}
6771

6872
static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
6973
{
70-
kmem_cache_free(pgtable_cache, pte);
74+
free_page((unsigned long)pte);
7175
}
7276

7377
static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
7478
{
7579
pgtable_page_dtor(pte);
76-
kmem_cache_free(pgtable_cache, page_address(pte));
80+
__free_page(pte);
7781
}
7882
#define pmd_pgtable(pmd) pmd_page(pmd)
7983

‎arch/xtensa/include/asm/pgtable.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,11 @@ extern unsigned long empty_zero_page[1024];
220220
#ifdef CONFIG_MMU
221221
extern pgd_t swapper_pg_dir[PAGE_SIZE/sizeof(pgd_t)];
222222
extern void paging_init(void);
223-
extern void pgtable_cache_init(void);
224223
#else
225224
# define swapper_pg_dir NULL
226225
static inline void paging_init(void) { }
227-
static inline void pgtable_cache_init(void) { }
228226
#endif
227+
static inline void pgtable_cache_init(void) { }
229228

230229
/*
231230
* The pmd contains the kernel virtual address of the pte page.

‎arch/xtensa/mm/mmu.c‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,3 @@ void __init init_mmu(void)
5050
*/
5151
set_ptevaddr_register(PGTABLE_START);
5252
}
53-
54-
struct kmem_cache *pgtable_cache __read_mostly;
55-
56-
static void pgd_ctor(void *addr)
57-
{
58-
pte_t *ptep = (pte_t *)addr;
59-
int i;
60-
61-
for (i = 0; i < 1024; i++, ptep++)
62-
pte_clear(NULL, 0, ptep);
63-
64-
}
65-
66-
void __init pgtable_cache_init(void)
67-
{
68-
pgtable_cache = kmem_cache_create("pgd",
69-
PAGE_SIZE, PAGE_SIZE,
70-
SLAB_HWCACHE_ALIGN,
71-
pgd_ctor);
72-
}

0 commit comments

Comments
 (0)