summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Rapoport <rppt@linux.ibm.com>2019-07-11 23:57:57 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-07-12 14:05:45 -0400
commit28bcf5937536062d96ee0b581a76a0b1b652eec6 (patch)
treeb732f504e6771ca235b8ca9dff7b17983f65a005
parentbc3ace9b520f97d5650d096a5f95cac3fa64e204 (diff)
arm: switch to generic version of pte allocation
Replace __get_free_page() and alloc_pages() calls with the generic __pte_alloc_one_kernel() and __pte_alloc_one(). There is no functional change for the kernel PTE allocation. The difference for the user PTEs, is that the clear_pte_table() is now called after pgtable_page_ctor() and the addition of __GFP_ACCOUNT to the GFP flags. The conversion to the generic version of pte_free_kernel() removes the NULL check for pte. The pte_free() version on arm is identical to the generic one and can be simply dropped. Link: http://lkml.kernel.org/r/1557296232-15361-4-git-send-email-rppt@linux.ibm.com Signed-off-by: Mike Rapoport <rppt@linux.ibm.com> Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: Anshuman Khandual <anshuman.khandual@arm.com> Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Greentime Hu <green.hu@gmail.com> Cc: Guan Xuetao <gxt@pku.edu.cn> Cc: Guo Ren <guoren@kernel.org> Cc: Guo Ren <ren_guo@c-sky.com> Cc: Helge Deller <deller@gmx.de> Cc: Ley Foon Tan <lftan@altera.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: Matt Turner <mattst88@gmail.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Michal Hocko <mhocko@suse.com> Cc: Palmer Dabbelt <palmer@sifive.com> Cc: Paul Burton <paul.burton@mips.com> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Richard Kuo <rkuo@codeaurora.org> Cc: Richard Weinberger <richard@nod.at> Cc: Russell King <linux@armlinux.org.uk> Cc: Sam Creasey <sammy@sammy.net> Cc: Vincent Chen <deanbo422@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/arm/include/asm/pgalloc.h41
-rw-r--r--arch/arm/mm/mmu.c2
2 files changed, 14 insertions, 29 deletions
diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
index c038cff6fdd3..a2a68b751971 100644
--- a/arch/arm/include/asm/pgalloc.h
+++ b/arch/arm/include/asm/pgalloc.h
@@ -54,8 +54,6 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
54extern pgd_t *pgd_alloc(struct mm_struct *mm); 54extern pgd_t *pgd_alloc(struct mm_struct *mm);
55extern void pgd_free(struct mm_struct *mm, pgd_t *pgd); 55extern void pgd_free(struct mm_struct *mm, pgd_t *pgd);
56 56
57#define PGALLOC_GFP (GFP_KERNEL | __GFP_ZERO)
58
59static inline void clean_pte_table(pte_t *pte) 57static inline void clean_pte_table(pte_t *pte)
60{ 58{
61 clean_dcache_area(pte + PTE_HWTABLE_PTRS, PTE_HWTABLE_SIZE); 59 clean_dcache_area(pte + PTE_HWTABLE_PTRS, PTE_HWTABLE_SIZE);
@@ -77,54 +75,41 @@ static inline void clean_pte_table(pte_t *pte)
77 * | h/w pt 1 | 75 * | h/w pt 1 |
78 * +------------+ 76 * +------------+
79 */ 77 */
78
79#define __HAVE_ARCH_PTE_ALLOC_ONE_KERNEL
80#define __HAVE_ARCH_PTE_ALLOC_ONE
81#include <asm-generic/pgalloc.h>
82
80static inline pte_t * 83static inline pte_t *
81pte_alloc_one_kernel(struct mm_struct *mm) 84pte_alloc_one_kernel(struct mm_struct *mm)
82{ 85{
83 pte_t *pte; 86 pte_t *pte = __pte_alloc_one_kernel(mm);
84 87
85 pte = (pte_t *)__get_free_page(PGALLOC_GFP);
86 if (pte) 88 if (pte)
87 clean_pte_table(pte); 89 clean_pte_table(pte);
88 90
89 return pte; 91 return pte;
90} 92}
91 93
94#ifdef CONFIG_HIGHPTE
95#define PGTABLE_HIGHMEM __GFP_HIGHMEM
96#else
97#define PGTABLE_HIGHMEM 0
98#endif
99
92static inline pgtable_t 100static inline pgtable_t
93pte_alloc_one(struct mm_struct *mm) 101pte_alloc_one(struct mm_struct *mm)
94{ 102{
95 struct page *pte; 103 struct page *pte;
96 104
97#ifdef CONFIG_HIGHPTE 105 pte = __pte_alloc_one(mm, GFP_PGTABLE_USER | PGTABLE_HIGHMEM);
98 pte = alloc_pages(PGALLOC_GFP | __GFP_HIGHMEM, 0);
99#else
100 pte = alloc_pages(PGALLOC_GFP, 0);
101#endif
102 if (!pte) 106 if (!pte)
103 return NULL; 107 return NULL;
104 if (!PageHighMem(pte)) 108 if (!PageHighMem(pte))
105 clean_pte_table(page_address(pte)); 109 clean_pte_table(page_address(pte));
106 if (!pgtable_page_ctor(pte)) {
107 __free_page(pte);
108 return NULL;
109 }
110 return pte; 110 return pte;
111} 111}
112 112
113/*
114 * Free one PTE table.
115 */
116static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
117{
118 if (pte)
119 free_page((unsigned long)pte);
120}
121
122static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
123{
124 pgtable_page_dtor(pte);
125 __free_page(pte);
126}
127
128static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte, 113static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
129 pmdval_t prot) 114 pmdval_t prot)
130{ 115{
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 1aa2586fa597..d9a0038774a6 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -729,7 +729,7 @@ static void __init *early_alloc(unsigned long sz)
729 729
730static void *__init late_alloc(unsigned long sz) 730static void *__init late_alloc(unsigned long sz)
731{ 731{
732 void *ptr = (void *)__get_free_pages(PGALLOC_GFP, get_order(sz)); 732 void *ptr = (void *)__get_free_pages(GFP_PGTABLE_KERNEL, get_order(sz));
733 733
734 if (!ptr || !pgtable_page_ctor(virt_to_page(ptr))) 734 if (!ptr || !pgtable_page_ctor(virt_to_page(ptr)))
735 BUG(); 735 BUG();