mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	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>
This commit is contained in:
		
							parent
							
								
									d9e8b92967
								
							
						
					
					
						commit
						f9cb654cb5
					
				
					 19 changed files with 18 additions and 62 deletions
				
			
		| 
						 | 
				
			
			@ -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 */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);			\
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);			\
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 *);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 {							\
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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; }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue