Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

asm-generic: pgalloc: provide generic pgd_free()

Most architectures define pgd_free() as a wrapper for free_page().

Provide a generic version in asm-generic/pgalloc.h and enable its use for
most architectures.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Pekka Enberg <penberg@kernel.org>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> [m68k]
Cc: Abdul Haleem <abdhalee@linux.vnet.ibm.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Joerg Roedel <jroedel@suse.de>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Satheesh Rajendran <sathnaga@linux.vnet.ibm.com>
Cc: Stafford Horne <shorne@gmail.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Matthew Wilcox <willy@infradead.org>
Link: http://lkml.kernel.org/r/20200627143453.31835-7-rppt@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Mike Rapoport and committed by
Linus Torvalds
f9cb654c d9e8b929

+18 -62
-6
arch/alpha/include/asm/pgalloc.h
··· 34 34 35 35 extern pgd_t *pgd_alloc(struct mm_struct *mm); 36 36 37 - static inline void 38 - pgd_free(struct mm_struct *mm, pgd_t *pgd) 39 - { 40 - free_page((unsigned long)pgd); 41 - } 42 - 43 37 #endif /* _ALPHA_PGALLOC_H */
+1
arch/arm/include/asm/pgalloc.h
··· 65 65 66 66 #define __HAVE_ARCH_PTE_ALLOC_ONE_KERNEL 67 67 #define __HAVE_ARCH_PTE_ALLOC_ONE 68 + #define __HAVE_ARCH_PGD_FREE 68 69 #include <asm-generic/pgalloc.h> 69 70 70 71 static inline pte_t *
+1
arch/arm64/include/asm/pgalloc.h
··· 13 13 #include <asm/cacheflush.h> 14 14 #include <asm/tlbflush.h> 15 15 16 + #define __HAVE_ARCH_PGD_FREE 16 17 #include <asm-generic/pgalloc.h> 17 18 18 19 #define PGD_SIZE (PTRS_PER_PGD * sizeof(pgd_t))
+1 -6
arch/csky/include/asm/pgalloc.h
··· 9 9 #include <linux/sched.h> 10 10 11 11 #define __HAVE_ARCH_PTE_ALLOC_ONE_KERNEL 12 - #include <asm-generic/pgalloc.h> /* for pte_{alloc,free}_one */ 12 + #include <asm-generic/pgalloc.h> 13 13 14 14 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, 15 15 pte_t *pte) ··· 40 40 (pte + i)->pte_low = _PAGE_GLOBAL; 41 41 42 42 return pte; 43 - } 44 - 45 - static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) 46 - { 47 - free_pages((unsigned long)pgd, PGD_ORDER); 48 43 } 49 44 50 45 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
+1 -6
arch/hexagon/include/asm/pgalloc.h
··· 11 11 #include <asm/mem-layout.h> 12 12 #include <asm/atomic.h> 13 13 14 - #include <asm-generic/pgalloc.h> /* for pte_{alloc,free}_one */ 14 + #include <asm-generic/pgalloc.h> 15 15 16 16 extern unsigned long long kmap_generation; 17 17 ··· 39 39 mm->context.ptbase = __pa(pgd); 40 40 41 41 return pgd; 42 - } 43 - 44 - static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) 45 - { 46 - free_page((unsigned long) pgd); 47 42 } 48 43 49 44 static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
-5
arch/ia64/include/asm/pgalloc.h
··· 29 29 return (pgd_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO); 30 30 } 31 31 32 - static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) 33 - { 34 - free_page((unsigned long)pgd); 35 - } 36 - 37 32 #if CONFIG_PGTABLE_LEVELS == 4 38 33 static inline void 39 34 p4d_populate(struct mm_struct *mm, p4d_t * p4d_entry, pud_t * pud)
+1 -6
arch/m68k/include/asm/sun3_pgalloc.h
··· 13 13 14 14 #include <asm/tlb.h> 15 15 16 - #include <asm-generic/pgalloc.h> /* for pte_{alloc,free}_one */ 16 + #include <asm-generic/pgalloc.h> 17 17 18 18 extern const char bad_pmd_string[]; 19 19 ··· 39 39 * inside the pgd, so has no extra memory associated with it. 40 40 */ 41 41 #define pmd_free(mm, x) do { } while (0) 42 - 43 - static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) 44 - { 45 - free_page((unsigned long) pgd); 46 - } 47 42 48 43 static inline pgd_t * pgd_alloc(struct mm_struct *mm) 49 44 {
-6
arch/microblaze/include/asm/pgalloc.h
··· 28 28 return (pgd_t *)__get_free_pages(GFP_KERNEL|__GFP_ZERO, 0); 29 29 } 30 30 31 - static inline void free_pgd(pgd_t *pgd) 32 - { 33 - free_page((unsigned long)pgd); 34 - } 35 - 36 - #define pgd_free(mm, pgd) free_pgd(pgd) 37 31 #define pgd_alloc(mm) get_pgd() 38 32 39 33 #define pmd_pgtable(pmd) pmd_page(pmd)
-5
arch/mips/include/asm/pgalloc.h
··· 49 49 extern void pgd_init(unsigned long page); 50 50 extern pgd_t *pgd_alloc(struct mm_struct *mm); 51 51 52 - static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) 53 - { 54 - free_pages((unsigned long)pgd, PGD_ORDER); 55 - } 56 - 57 52 #define __pte_free_tlb(tlb,pte,address) \ 58 53 do { \ 59 54 pgtable_pte_page_dtor(pte); \
+2
arch/nds32/mm/mm-nds32.c
··· 2 2 // Copyright (C) 2005-2017 Andes Technology Corporation 3 3 4 4 #include <linux/init_task.h> 5 + 6 + #define __HAVE_ARCH_PGD_FREE 5 7 #include <asm/pgalloc.h> 6 8 7 9 #define FIRST_KERNEL_PGD_NR (USER_PTRS_PER_PGD)
+1 -6
arch/nios2/include/asm/pgalloc.h
··· 12 12 13 13 #include <linux/mm.h> 14 14 15 - #include <asm-generic/pgalloc.h> /* for pte_{alloc,free}_one */ 15 + #include <asm-generic/pgalloc.h> 16 16 17 17 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, 18 18 pte_t *pte) ··· 33 33 extern void pmd_init(unsigned long page, unsigned long pagetable); 34 34 35 35 extern pgd_t *pgd_alloc(struct mm_struct *mm); 36 - 37 - static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) 38 - { 39 - free_pages((unsigned long)pgd, PGD_ORDER); 40 - } 41 36 42 37 #define __pte_free_tlb(tlb, pte, addr) \ 43 38 do { \
+1
arch/parisc/include/asm/pgalloc.h
··· 11 11 #include <asm/cache.h> 12 12 13 13 #define __HAVE_ARCH_PMD_FREE 14 + #define __HAVE_ARCH_PGD_FREE 14 15 #include <asm-generic/pgalloc.h> 15 16 16 17 /* Allocate the top level pgd (page directory)
-5
arch/riscv/include/asm/pgalloc.h
··· 55 55 return pgd; 56 56 } 57 57 58 - static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) 59 - { 60 - free_page((unsigned long)pgd); 61 - } 62 - 63 58 #ifndef __PAGETABLE_PMD_FOLDED 64 59 65 60 #define __pmd_free_tlb(tlb, pmd, addr) pmd_free((tlb)->mm, pmd)
+1
arch/sh/include/asm/pgalloc.h
··· 6 6 7 7 #define __HAVE_ARCH_PMD_ALLOC_ONE 8 8 #define __HAVE_ARCH_PMD_FREE 9 + #define __HAVE_ARCH_PGD_FREE 9 10 #include <asm-generic/pgalloc.h> 10 11 11 12 extern pgd_t *pgd_alloc(struct mm_struct *);
-1
arch/um/include/asm/pgalloc.h
··· 25 25 * Allocate and free page tables. 26 26 */ 27 27 extern pgd_t *pgd_alloc(struct mm_struct *); 28 - extern void pgd_free(struct mm_struct *mm, pgd_t *pgd); 29 28 30 29 #define __pte_free_tlb(tlb,pte, address) \ 31 30 do { \
-5
arch/um/kernel/mem.c
··· 196 196 return pgd; 197 197 } 198 198 199 - void pgd_free(struct mm_struct *mm, pgd_t *pgd) 200 - { 201 - free_page((unsigned long) pgd); 202 - } 203 - 204 199 void *uml_kmalloc(int size, int flags) 205 200 { 206 201 return kmalloc(size, flags);
+1
arch/x86/include/asm/pgalloc.h
··· 7 7 #include <linux/pagemap.h> 8 8 9 9 #define __HAVE_ARCH_PTE_ALLOC_ONE 10 + #define __HAVE_ARCH_PGD_FREE 10 11 #include <asm-generic/pgalloc.h> 11 12 12 13 static inline int __paravirt_pgd_alloc(struct mm_struct *mm) { return 0; }
-5
arch/xtensa/include/asm/pgalloc.h
··· 33 33 return (pgd_t*) __get_free_pages(GFP_KERNEL | __GFP_ZERO, PGD_ORDER); 34 34 } 35 35 36 - static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) 37 - { 38 - free_page((unsigned long)pgd); 39 - } 40 - 41 36 static inline void ptes_clear(pte_t *ptep) 42 37 { 43 38 int i;
+7
include/asm-generic/pgalloc.h
··· 175 175 176 176 #endif /* CONFIG_PGTABLE_LEVELS > 3 */ 177 177 178 + #ifndef __HAVE_ARCH_PGD_FREE 179 + static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) 180 + { 181 + free_page((unsigned long)pgd); 182 + } 183 + #endif 184 + 178 185 #endif /* CONFIG_MMU */ 179 186 180 187 #endif /* __ASM_GENERIC_PGALLOC_H */