Skip to content

Commit f9cb654

Browse files
rppttorvalds
authored andcommitted
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>
1 parent d9e8b92 commit f9cb654

19 files changed

Lines changed: 18 additions & 62 deletions

File tree

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,4 @@ pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
3434

3535
extern pgd_t *pgd_alloc(struct mm_struct *mm);
3636

37-
static inline void
38-
pgd_free(struct mm_struct *mm, pgd_t *pgd)
39-
{
40-
free_page((unsigned long)pgd);
41-
}
42-
4337
#endif /* _ALPHA_PGALLOC_H */

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ static inline void clean_pte_table(pte_t *pte)
6565

6666
#define __HAVE_ARCH_PTE_ALLOC_ONE_KERNEL
6767
#define __HAVE_ARCH_PTE_ALLOC_ONE
68+
#define __HAVE_ARCH_PGD_FREE
6869
#include <asm-generic/pgalloc.h>
6970

7071
static inline pte_t *

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <asm/cacheflush.h>
1414
#include <asm/tlbflush.h>
1515

16+
#define __HAVE_ARCH_PGD_FREE
1617
#include <asm-generic/pgalloc.h>
1718

1819
#define PGD_SIZE (PTRS_PER_PGD * sizeof(pgd_t))

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <linux/sched.h>
1010

1111
#define __HAVE_ARCH_PTE_ALLOC_ONE_KERNEL
12-
#include <asm-generic/pgalloc.h> /* for pte_{alloc,free}_one */
12+
#include <asm-generic/pgalloc.h>
1313

1414
static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
1515
pte_t *pte)
@@ -42,11 +42,6 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
4242
return pte;
4343
}
4444

45-
static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
46-
{
47-
free_pages((unsigned long)pgd, PGD_ORDER);
48-
}
49-
5045
static inline pgd_t *pgd_alloc(struct mm_struct *mm)
5146
{
5247
pgd_t *ret;

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <asm/mem-layout.h>
1212
#include <asm/atomic.h>
1313

14-
#include <asm-generic/pgalloc.h> /* for pte_{alloc,free}_one */
14+
#include <asm-generic/pgalloc.h>
1515

1616
extern unsigned long long kmap_generation;
1717

@@ -41,11 +41,6 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)
4141
return pgd;
4242
}
4343

44-
static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
45-
{
46-
free_page((unsigned long) pgd);
47-
}
48-
4944
static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
5045
pgtable_t pte)
5146
{

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)
2929
return (pgd_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
3030
}
3131

32-
static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
33-
{
34-
free_page((unsigned long)pgd);
35-
}
36-
3732
#if CONFIG_PGTABLE_LEVELS == 4
3833
static inline void
3934
p4d_populate(struct mm_struct *mm, p4d_t * p4d_entry, pud_t * pud)

‎arch/m68k/include/asm/sun3_pgalloc.h‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include <asm/tlb.h>
1515

16-
#include <asm-generic/pgalloc.h> /* for pte_{alloc,free}_one */
16+
#include <asm-generic/pgalloc.h>
1717

1818
extern const char bad_pmd_string[];
1919

@@ -40,11 +40,6 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, pgtable_t page
4040
*/
4141
#define pmd_free(mm, x) do { } while (0)
4242

43-
static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
44-
{
45-
free_page((unsigned long) pgd);
46-
}
47-
4843
static inline pgd_t * pgd_alloc(struct mm_struct *mm)
4944
{
5045
pgd_t *new_pgd;

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ static inline pgd_t *get_pgd(void)
2828
return (pgd_t *)__get_free_pages(GFP_KERNEL|__GFP_ZERO, 0);
2929
}
3030

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)
3731
#define pgd_alloc(mm) get_pgd()
3832

3933
#define pmd_pgtable(pmd) pmd_page(pmd)

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
4949
extern void pgd_init(unsigned long page);
5050
extern pgd_t *pgd_alloc(struct mm_struct *mm);
5151

52-
static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
53-
{
54-
free_pages((unsigned long)pgd, PGD_ORDER);
55-
}
56-
5752
#define __pte_free_tlb(tlb,pte,address) \
5853
do { \
5954
pgtable_pte_page_dtor(pte); \

‎arch/nds32/mm/mm-nds32.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Copyright (C) 2005-2017 Andes Technology Corporation
33

44
#include <linux/init_task.h>
5+
6+
#define __HAVE_ARCH_PGD_FREE
57
#include <asm/pgalloc.h>
68

79
#define FIRST_KERNEL_PGD_NR (USER_PTRS_PER_PGD)

0 commit comments

Comments
 (0)