asm-generic: pgalloc: provide generic pgd_free()
authorMike Rapoport <rppt@linux.ibm.com>
Fri, 7 Aug 2020 06:22:47 +0000 (23:22 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 7 Aug 2020 18:33:26 +0000 (11:33 -0700)
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>
19 files changed:
arch/alpha/include/asm/pgalloc.h
arch/arm/include/asm/pgalloc.h
arch/arm64/include/asm/pgalloc.h
arch/csky/include/asm/pgalloc.h
arch/hexagon/include/asm/pgalloc.h
arch/ia64/include/asm/pgalloc.h
arch/m68k/include/asm/sun3_pgalloc.h
arch/microblaze/include/asm/pgalloc.h
arch/mips/include/asm/pgalloc.h
arch/nds32/mm/mm-nds32.c
arch/nios2/include/asm/pgalloc.h
arch/parisc/include/asm/pgalloc.h
arch/riscv/include/asm/pgalloc.h
arch/sh/include/asm/pgalloc.h
arch/um/include/asm/pgalloc.h
arch/um/kernel/mem.c
arch/x86/include/asm/pgalloc.h
arch/xtensa/include/asm/pgalloc.h
include/asm-generic/pgalloc.h

index 4834cd52e9d0be915318c58d94b2db1ee30a449f..9c6a24fe493d59e88303647c2ed80e6a4f53c136 100644 (file)
@@ -34,10 +34,4 @@ pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
 
 extern pgd_t *pgd_alloc(struct mm_struct *mm);
 
-static inline void
-pgd_free(struct mm_struct *mm, pgd_t *pgd)
-{
-       free_page((unsigned long)pgd);
-}
-
 #endif /* _ALPHA_PGALLOC_H */
index c5bdfd404ea58e5bcb0970dc7dad4203e324060e..15f4674715f8479201e84664eb22f17a701c7bd8 100644 (file)
@@ -65,6 +65,7 @@ static inline void clean_pte_table(pte_t *pte)
 
 #define __HAVE_ARCH_PTE_ALLOC_ONE_KERNEL
 #define __HAVE_ARCH_PTE_ALLOC_ONE
+#define __HAVE_ARCH_PGD_FREE
 #include <asm-generic/pgalloc.h>
 
 static inline pte_t *
index 0965945b595d012fcca81e551248d3248cddcc96..3c6a7f5988b127e54b14d422489feda06d03f847 100644 (file)
@@ -13,6 +13,7 @@
 #include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
 
+#define __HAVE_ARCH_PGD_FREE
 #include <asm-generic/pgalloc.h>
 
 #define PGD_SIZE       (PTRS_PER_PGD * sizeof(pgd_t))
index c7c1ed27e34804f16c30f5be0393afddb15c37a2..d58d8146b729c4f8259a2bc1ce2cd805e5b39f41 100644 (file)
@@ -9,7 +9,7 @@
 #include <linux/sched.h>
 
 #define __HAVE_ARCH_PTE_ALLOC_ONE_KERNEL
-#include <asm-generic/pgalloc.h>       /* for pte_{alloc,free}_one */
+#include <asm-generic/pgalloc.h>
 
 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
                                        pte_t *pte)
@@ -42,11 +42,6 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
        return pte;
 }
 
-static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
-{
-       free_pages((unsigned long)pgd, PGD_ORDER);
-}
-
 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
 {
        pgd_t *ret;
index cc9be514a676a5016dc4e0a05517d3c70727211c..f0c47e6a7427d41d8775c9fdff6a64437cc072e3 100644 (file)
@@ -11,7 +11,7 @@
 #include <asm/mem-layout.h>
 #include <asm/atomic.h>
 
-#include <asm-generic/pgalloc.h>       /* for pte_{alloc,free}_one */
+#include <asm-generic/pgalloc.h>
 
 extern unsigned long long kmap_generation;
 
@@ -41,11 +41,6 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)
        return pgd;
 }
 
-static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
-{
-       free_page((unsigned long) pgd);
-}
-
 static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
                                pgtable_t pte)
 {
index 06f80358e20fdd4679b34a044f1bcf9dadde1afc..9601cfe83c9406e85fca0825c74790519795d424 100644 (file)
@@ -29,11 +29,6 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)
        return (pgd_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
 }
 
-static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
-{
-       free_page((unsigned long)pgd);
-}
-
 #if CONFIG_PGTABLE_LEVELS == 4
 static inline void
 p4d_populate(struct mm_struct *mm, p4d_t * p4d_entry, pud_t * pud)
index 11b95dadf7c058afd2b638781483badf3d0c3f12..000f64869b919e4687a390a6e01d9d605bc03ee2 100644 (file)
@@ -13,7 +13,7 @@
 
 #include <asm/tlb.h>
 
-#include <asm-generic/pgalloc.h>       /* for pte_{alloc,free}_one */
+#include <asm-generic/pgalloc.h>
 
 extern const char bad_pmd_string[];
 
@@ -40,11 +40,6 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, pgtable_t page
  */
 #define pmd_free(mm, x)                        do { } while (0)
 
-static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
-{
-        free_page((unsigned long) pgd);
-}
-
 static inline pgd_t * pgd_alloc(struct mm_struct *mm)
 {
      pgd_t *new_pgd;
index ebb6b7939bb82bdd8ed803a12388eb9aecf14751..8839ce00ea051535c391af4cd534aa0620d8d620 100644 (file)
@@ -28,12 +28,6 @@ static inline pgd_t *get_pgd(void)
        return (pgd_t *)__get_free_pages(GFP_KERNEL|__GFP_ZERO, 0);
 }
 
-static inline void free_pgd(pgd_t *pgd)
-{
-       free_page((unsigned long)pgd);
-}
-
-#define pgd_free(mm, pgd)      free_pgd(pgd)
 #define pgd_alloc(mm)          get_pgd()
 
 #define pmd_pgtable(pmd)       pmd_page(pmd)
index e5a840910ce0707361cfcd9c0a26b6b3225c0383..8b18424b31208c36a92514beecd8b9efc98ae7a2 100644 (file)
@@ -49,11 +49,6 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
 extern void pgd_init(unsigned long page);
 extern pgd_t *pgd_alloc(struct mm_struct *mm);
 
-static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
-{
-       free_pages((unsigned long)pgd, PGD_ORDER);
-}
-
 #define __pte_free_tlb(tlb,pte,address)                        \
 do {                                                   \
        pgtable_pte_page_dtor(pte);                     \
index 8503bee882d1810898da24686b4f70e3b4020c14..55bec50ccc03318ed472ebfa21033b46bac892f4 100644 (file)
@@ -2,6 +2,8 @@
 // Copyright (C) 2005-2017 Andes Technology Corporation
 
 #include <linux/init_task.h>
+
+#define __HAVE_ARCH_PGD_FREE
 #include <asm/pgalloc.h>
 
 #define FIRST_KERNEL_PGD_NR    (USER_PTRS_PER_PGD)
index 0b146d773c85d7dd6c4f09f90d0140f8c204ac82..e6600d2a5ae052982bbb6c271f87d5ce14d2df00 100644 (file)
@@ -12,7 +12,7 @@
 
 #include <linux/mm.h>
 
-#include <asm-generic/pgalloc.h>       /* for pte_{alloc,free}_one */
+#include <asm-generic/pgalloc.h>
 
 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
        pte_t *pte)
@@ -34,11 +34,6 @@ extern void pmd_init(unsigned long page, unsigned long pagetable);
 
 extern pgd_t *pgd_alloc(struct mm_struct *mm);
 
-static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
-{
-       free_pages((unsigned long)pgd, PGD_ORDER);
-}
-
 #define __pte_free_tlb(tlb, pte, addr)                         \
        do {                                                    \
                pgtable_pte_page_dtor(pte);                     \
index 689766b914ed02c490571abb76e885890cbe5ca1..cc7ecc2ef55d67bc40532d649dd437682506f182 100644 (file)
@@ -11,6 +11,7 @@
 #include <asm/cache.h>
 
 #define __HAVE_ARCH_PMD_FREE
+#define __HAVE_ARCH_PGD_FREE
 #include <asm-generic/pgalloc.h>
 
 /* Allocate the top level pgd (page directory)
index 8d3135f05b8e2670bd5d29061dac156a6908ead7..23b1544e0ca5b322aefa8cf83af5c528a8b10498 100644 (file)
@@ -55,11 +55,6 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)
        return pgd;
 }
 
-static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
-{
-       free_page((unsigned long)pgd);
-}
-
 #ifndef __PAGETABLE_PMD_FOLDED
 
 #define __pmd_free_tlb(tlb, pmd, addr)  pmd_free((tlb)->mm, pmd)
index 811afb567101911776e2ab9a8c63490d82d031ab..0e6b0be25e33be4a2c986a385014ccf81976633a 100644 (file)
@@ -6,6 +6,7 @@
 
 #define __HAVE_ARCH_PMD_ALLOC_ONE
 #define __HAVE_ARCH_PMD_FREE
+#define __HAVE_ARCH_PGD_FREE
 #include <asm-generic/pgalloc.h>
 
 extern pgd_t *pgd_alloc(struct mm_struct *);
index bdde433dbdec5f729d50fa36e3a2589435dc5944..5393e13e07e0a9108addf8dfa2e05c1343a290e7 100644 (file)
@@ -25,7 +25,6 @@
  * Allocate and free page tables.
  */
 extern pgd_t *pgd_alloc(struct mm_struct *);
-extern void pgd_free(struct mm_struct *mm, pgd_t *pgd);
 
 #define __pte_free_tlb(tlb,pte, address)               \
 do {                                                   \
index a4accb14cbd5a0e9868f0eaab41ab6ab4a0c1dda..9242dc91d75193475cb105b4e6e6ab016f1a7a08 100644 (file)
@@ -196,11 +196,6 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
        return pgd;
 }
 
-void pgd_free(struct mm_struct *mm, pgd_t *pgd)
-{
-       free_page((unsigned long) pgd);
-}
-
 void *uml_kmalloc(int size, int flags)
 {
        return kmalloc(size, flags);
index 3d1085a1434706f2584d8c105d808c0109777759..62ad61d6fefcb32acf235544d7364b68c7b2fc3b 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/pagemap.h>
 
 #define __HAVE_ARCH_PTE_ALLOC_ONE
+#define __HAVE_ARCH_PGD_FREE
 #include <asm-generic/pgalloc.h>
 
 static inline int  __paravirt_pgd_alloc(struct mm_struct *mm) { return 0; }
index 5553abed69330d34a449be7b2fb7d3dbece1efed..d3a22da4d2c91b91fbeaeee316f4c2e3efd38529 100644 (file)
@@ -33,11 +33,6 @@ pgd_alloc(struct mm_struct *mm)
        return (pgd_t*) __get_free_pages(GFP_KERNEL | __GFP_ZERO, PGD_ORDER);
 }
 
-static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
-{
-       free_page((unsigned long)pgd);
-}
-
 static inline void ptes_clear(pte_t *ptep)
 {
        int i;
index d361574aaadff99532117808b6b38d2016b1faeb..6f44810921aa1ba515a0d9222c339c9b35c70b64 100644 (file)
@@ -175,6 +175,13 @@ static inline void pud_free(struct mm_struct *mm, pud_t *pud)
 
 #endif /* CONFIG_PGTABLE_LEVELS > 3 */
 
+#ifndef __HAVE_ARCH_PGD_FREE
+static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
+{
+       free_page((unsigned long)pgd);
+}
+#endif
+
 #endif /* CONFIG_MMU */
 
 #endif /* __ASM_GENERIC_PGALLOC_H */