Skip to content

Commit 7278914

Browse files
rppttorvalds
authored andcommitted
xtensa: switch to generic version of pte allocation
xtensa clears PTEs during allocation of the page tables and pte_clear() sets the PTE to a non-zero value. Splitting ptes_clear() helper out of pte_alloc_one() and pte_alloc_one_kernel() allows reuse of base generic allocation methods (__pte_alloc_one() and __pte_alloc_one_kernel()) and the common GFP mask for page table allocations. The pte_free() and pte_free_kernel() implementations on xtensa are identical to the generic ones and can be dropped. [[email protected]: xtensa: fix closing endif comment] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Mike Rapoport <[email protected]> Signed-off-by: Max Filippov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Reviewed-by: Pekka Enberg <[email protected]> Cc: Abdul Haleem <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Christophe Leroy <[email protected]> Cc: Joerg Roedel <[email protected]> Cc: Joerg Roedel <[email protected]> Cc: Max Filippov <[email protected]> Cc: Peter Zijlstra (Intel) <[email protected]> Cc: Satheesh Rajendran <[email protected]> Cc: Stafford Horne <[email protected]> Cc: Stephen Rothwell <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Matthew Wilcox <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent fc2a6b8 commit 7278914

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

arch/xtensa/include/asm/pgalloc.h

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@
88
#ifndef _XTENSA_PGALLOC_H
99
#define _XTENSA_PGALLOC_H
1010

11+
#ifdef CONFIG_MMU
1112
#include <linux/highmem.h>
1213
#include <linux/slab.h>
1314

15+
#define __HAVE_ARCH_PTE_ALLOC_ONE_KERNEL
16+
#define __HAVE_ARCH_PTE_ALLOC_ONE
17+
#include <asm-generic/pgalloc.h>
18+
1419
/*
1520
* Allocating and freeing a pmd is trivial: the 1-entry pmd is
1621
* inside the pgd, so has no extra memory associated with it.
@@ -33,45 +38,37 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
3338
free_page((unsigned long)pgd);
3439
}
3540

41+
static inline void ptes_clear(pte_t *ptep)
42+
{
43+
int i;
44+
45+
for (i = 0; i < PTRS_PER_PTE; i++)
46+
pte_clear(NULL, 0, ptep + i);
47+
}
48+
3649
static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
3750
{
3851
pte_t *ptep;
39-
int i;
4052

41-
ptep = (pte_t *)__get_free_page(GFP_KERNEL);
53+
ptep = (pte_t *)__pte_alloc_one_kernel(mm);
4254
if (!ptep)
4355
return NULL;
44-
for (i = 0; i < 1024; i++)
45-
pte_clear(NULL, 0, ptep + i);
56+
ptes_clear(ptep);
4657
return ptep;
4758
}
4859

4960
static inline pgtable_t pte_alloc_one(struct mm_struct *mm)
5061
{
51-
pte_t *pte;
5262
struct page *page;
5363

54-
pte = pte_alloc_one_kernel(mm);
55-
if (!pte)
56-
return NULL;
57-
page = virt_to_page(pte);
58-
if (!pgtable_pte_page_ctor(page)) {
59-
__free_page(page);
64+
page = __pte_alloc_one(mm, GFP_PGTABLE_USER);
65+
if (!page)
6066
return NULL;
61-
}
67+
ptes_clear(page_address(page));
6268
return page;
6369
}
6470

65-
static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
66-
{
67-
free_page((unsigned long)pte);
68-
}
69-
70-
static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
71-
{
72-
pgtable_pte_page_dtor(pte);
73-
__free_page(pte);
74-
}
7571
#define pmd_pgtable(pmd) pmd_page(pmd)
72+
#endif /* CONFIG_MMU */
7673

7774
#endif /* _XTENSA_PGALLOC_H */

0 commit comments

Comments
 (0)