Skip to content

Commit

Permalink
mm: consolidate pgtable_cache_init() and pgd_cache_init()
Browse files Browse the repository at this point in the history
Both pgtable_cache_init() and pgd_cache_init() are used to initialize kmem
cache for page table allocations on several architectures that do not use
PAGE_SIZE tables for one or more levels of the page table hierarchy.

Most architectures do not implement these functions and use __weak default
NOP implementation of pgd_cache_init().  Since there is no such default
for pgtable_cache_init(), its empty stub is duplicated among most
architectures.

Rename the definitions of pgd_cache_init() to pgtable_cache_init() and
drop empty stubs of pgtable_cache_init().

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Mike Rapoport <[email protected]>
Acked-by: Will Deacon <[email protected]>		[arm64]
Acked-by: Thomas Gleixner <[email protected]>	[x86]
Cc: Catalin Marinas <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
rppt authored and torvalds committed Sep 24, 2019
1 parent 1b9a9d8 commit 782de70
Show file tree
Hide file tree
Showing 36 changed files with 5 additions and 130 deletions.
5 changes: 0 additions & 5 deletions arch/alpha/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,6 @@ extern void paging_init(void);

#include <asm-generic/pgtable.h>

/*
* No page table caches to initialise
*/
#define pgtable_cache_init() do { } while (0)

/* We have our own get_unmapped_area to cope with ADDR_LIMIT_32BIT. */
#define HAVE_ARCH_UNMAPPED_AREA

Expand Down
5 changes: 0 additions & 5 deletions arch/arc/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,11 +395,6 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
/* to cope with aliasing VIPT cache */
#define HAVE_ARCH_UNMAPPED_AREA

/*
* No page table caches to initialise
*/
#define pgtable_cache_init() do { } while (0)

#endif /* __ASSEMBLY__ */

#endif
5 changes: 0 additions & 5 deletions arch/arm/include/asm/pgtable-nommu.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ typedef pte_t *pte_addr_t;
*/
extern unsigned int kobjsize(const void *objp);

/*
* No page table caches to initialise.
*/
#define pgtable_cache_init() do { } while (0)

/*
* All 32bit addresses are effectively valid for vmalloc...
* Sort of meaningless for non-VM targets.
Expand Down
2 changes: 0 additions & 2 deletions arch/arm/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,6 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
#define HAVE_ARCH_UNMAPPED_AREA
#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN

#define pgtable_cache_init() do { } while (0)

#endif /* !__ASSEMBLY__ */

#endif /* CONFIG_MMU */
Expand Down
2 changes: 0 additions & 2 deletions arch/arm64/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -861,8 +861,6 @@ extern int kern_addr_valid(unsigned long addr);

#include <asm-generic/pgtable.h>

static inline void pgtable_cache_init(void) { }

/*
* On AArch64, the cache coherency is handled via the set_pte_at() function.
*/
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/mm/pgd.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void pgd_free(struct mm_struct *mm, pgd_t *pgd)
kmem_cache_free(pgd_cache, pgd);
}

void __init pgd_cache_init(void)
void __init pgtable_cache_init(void)
{
if (PGD_SIZE == PAGE_SIZE)
return;
Expand Down
5 changes: 0 additions & 5 deletions arch/c6x/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ extern unsigned long empty_zero_page;

#define swapper_pg_dir ((pgd_t *) 0)

/*
* No page table caches to initialise
*/
#define pgtable_cache_init() do { } while (0)

/*
* c6x is !MMU, so define the simpliest implementation
*/
Expand Down
5 changes: 0 additions & 5 deletions arch/csky/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,6 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
/* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
#define kern_addr_valid(addr) (1)

/*
* No page table caches to initialise
*/
#define pgtable_cache_init() do {} while (0)

#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
remap_pfn_range(vma, vaddr, pfn, size, prot)

Expand Down
6 changes: 0 additions & 6 deletions arch/h8300/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#define __ARCH_USE_5LEVEL_HACK
#include <asm-generic/pgtable-nopud.h>
#include <asm-generic/pgtable.h>
#define pgtable_cache_init() do { } while (0)
extern void paging_init(void);
#define PAGE_NONE __pgprot(0) /* these mean nothing to NO_MM */
#define PAGE_SHARED __pgprot(0) /* these mean nothing to NO_MM */
Expand Down Expand Up @@ -34,11 +33,6 @@ static inline int pte_file(pte_t pte) { return 0; }
extern unsigned int kobjsize(const void *objp);
extern int is_in_rom(unsigned long);

/*
* No page table caches to initialise
*/
#define pgtable_cache_init() do { } while (0)

/*
* All 32bit addresses are effectively valid for vmalloc...
* Sort of meaningless for non-VM targets.
Expand Down
3 changes: 0 additions & 3 deletions arch/hexagon/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,6 @@ static inline int pte_exec(pte_t pte)

#define __pte_offset(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))

/* I think this is in case we have page table caches; needed by init/main.c */
#define pgtable_cache_init() do { } while (0)

/*
* Swap/file PTE definitions. If _PAGE_PRESENT is zero, the rest of the PTE is
* interpreted as swap information. The remaining free bits are interpreted as
Expand Down
2 changes: 1 addition & 1 deletion arch/hexagon/mm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# Makefile for Hexagon memory management subsystem
#

obj-y := init.o pgalloc.o ioremap.o uaccess.o vm_fault.o cache.o
obj-y := init.o ioremap.o uaccess.o vm_fault.o cache.o
obj-y += copy_to_user.o copy_from_user.o strnlen_user.o vm_tlb.o
10 changes: 0 additions & 10 deletions arch/hexagon/mm/pgalloc.c

This file was deleted.

5 changes: 0 additions & 5 deletions arch/ia64/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -566,11 +566,6 @@ extern struct page *zero_page_memmap_ptr;
#define KERNEL_TR_PAGE_SHIFT _PAGE_SIZE_64M
#define KERNEL_TR_PAGE_SIZE (1 << KERNEL_TR_PAGE_SHIFT)

/*
* No page table caches to initialise
*/
#define pgtable_cache_init() do { } while (0)

/* These tell get_user_pages() that the first gate page is accessible from user-level. */
#define FIXADDR_USER_START GATE_ADDR
#ifdef HAVE_BUGGY_SEGREL
Expand Down
5 changes: 0 additions & 5 deletions arch/m68k/include/asm/pgtable_mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,4 @@ pgprot_t pgprot_dmacoherent(pgprot_t prot);
#include <asm-generic/pgtable.h>
#endif /* !__ASSEMBLY__ */

/*
* No page table caches to initialise
*/
#define pgtable_cache_init() do { } while (0)

#endif /* _M68K_PGTABLE_H */
5 changes: 0 additions & 5 deletions arch/m68k/include/asm/pgtable_no.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ extern void paging_init(void);
*/
#define ZERO_PAGE(vaddr) (virt_to_page(0))

/*
* No page table caches to initialise.
*/
#define pgtable_cache_init() do { } while (0)

/*
* All 32bit addresses are effectively valid for vmalloc...
* Sort of meaningless for non-VM targets.
Expand Down
7 changes: 0 additions & 7 deletions arch/microblaze/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ extern int mem_init_done;

#define swapper_pg_dir ((pgd_t *) NULL)

#define pgtable_cache_init() do {} while (0)

#define arch_enter_lazy_cpu_mode() do {} while (0)

#define pgprot_noncached_wc(prot) prot
Expand Down Expand Up @@ -526,11 +524,6 @@ extern unsigned long iopa(unsigned long addr);
/* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
#define kern_addr_valid(addr) (1)

/*
* No page table caches to initialise
*/
#define pgtable_cache_init() do { } while (0)

void do_page_fault(struct pt_regs *regs, unsigned long address,
unsigned long error_code);

Expand Down
5 changes: 0 additions & 5 deletions arch/mips/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,4 @@ pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
#define HAVE_ARCH_UNMAPPED_AREA
#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN

/*
* No page table caches to initialise
*/
#define pgtable_cache_init() do { } while (0)

#endif /* _ASM_PGTABLE_H */
2 changes: 0 additions & 2 deletions arch/nds32/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,6 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
* into virtual address `from'
*/

#define pgtable_cache_init() do { } while (0)

#endif /* !__ASSEMBLY__ */

#endif /* _ASMNDS32_PGTABLE_H */
2 changes: 0 additions & 2 deletions arch/nios2/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,6 @@ static inline void pte_clear(struct mm_struct *mm,

#include <asm-generic/pgtable.h>

#define pgtable_cache_init() do { } while (0)

extern void __init paging_init(void);
extern void __init mmu_init(void);

Expand Down
5 changes: 0 additions & 5 deletions arch/openrisc/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,11 +443,6 @@ static inline void update_mmu_cache(struct vm_area_struct *vma,

#include <asm-generic/pgtable.h>

/*
* No page table caches to initialise
*/
#define pgtable_cache_init() do { } while (0)

typedef pte_t *pte_addr_t;

#endif /* __ASSEMBLY__ */
Expand Down
2 changes: 0 additions & 2 deletions arch/parisc/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ static inline void purge_tlb_entries(struct mm_struct *mm, unsigned long addr)
#define PTRS_PER_PTE (1UL << BITS_PER_PTE)

/* Definitions for 2nd level */
#define pgtable_cache_init() do { } while (0)

#define PMD_SHIFT (PLD_SHIFT + BITS_PER_PTE)
#define PMD_SIZE (1UL << PMD_SHIFT)
#define PMD_MASK (~(PMD_SIZE-1))
Expand Down
1 change: 0 additions & 1 deletion arch/powerpc/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ extern unsigned long ioremap_bot;
unsigned long vmalloc_to_phys(void *vmalloc_addr);

void pgtable_cache_add(unsigned int shift);
void pgtable_cache_init(void);

#if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_PPC32)
void mark_initmem_nx(void);
Expand Down
5 changes: 0 additions & 5 deletions arch/riscv/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,6 @@ extern void *dtb_early_va;
extern void setup_bootmem(void);
extern void paging_init(void);

static inline void pgtable_cache_init(void)
{
/* No page table caches to initialize */
}

#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1)
#define VMALLOC_END (PAGE_OFFSET - 1)
#define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE)
Expand Down
5 changes: 0 additions & 5 deletions arch/s390/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -1682,11 +1682,6 @@ extern void s390_reset_cmma(struct mm_struct *mm);
#define HAVE_ARCH_UNMAPPED_AREA
#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN

/*
* No page table caches to initialise
*/
static inline void pgtable_cache_init(void) { }

#include <asm-generic/pgtable.h>

#endif /* _S390_PAGE_H */
5 changes: 0 additions & 5 deletions arch/sh/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ typedef pte_t *pte_addr_t;

#define pte_pfn(x) ((unsigned long)(((x).pte_low >> PAGE_SHIFT)))

/*
* Initialise the page table caches
*/
extern void pgtable_cache_init(void);

struct vm_area_struct;
struct mm_struct;

Expand Down
4 changes: 0 additions & 4 deletions arch/sh/mm/nommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,3 @@ void __init page_table_range_init(unsigned long start, unsigned long end,
void __set_fixmap(enum fixed_addresses idx, unsigned long phys, pgprot_t prot)
{
}

void pgtable_cache_init(void)
{
}
5 changes: 0 additions & 5 deletions arch/sparc/include/asm/pgtable_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,4 @@ static inline int io_remap_pfn_range(struct vm_area_struct *vma,
/* We provide our own get_unmapped_area to cope with VA holes for userland */
#define HAVE_ARCH_UNMAPPED_AREA

/*
* No page table caches to initialise
*/
#define pgtable_cache_init() do { } while (0)

#endif /* !(_SPARC_PGTABLE_H) */
1 change: 0 additions & 1 deletion arch/sparc/include/asm/pgtable_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,6 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long,
unsigned long);
#define HAVE_ARCH_FB_UNMAPPED_AREA

void pgtable_cache_init(void);
void sun4v_register_fault_status(void);
void sun4v_ktsb_register(void);
void __init cheetah_ecache_flush_init(void);
Expand Down
2 changes: 0 additions & 2 deletions arch/um/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
/* zero page used for uninitialized stuff */
extern unsigned long *empty_zero_page;

#define pgtable_cache_init() do ; while (0)

/* Just any arbitrary offset to the start of the vmalloc VM area: the
* current 8MB value just means that there will be a 8MB "hole" after the
* physical memory until the kernel virtual memory starts. That means that
Expand Down
2 changes: 0 additions & 2 deletions arch/unicore32/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,6 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];

#include <asm-generic/pgtable.h>

#define pgtable_cache_init() do { } while (0)

#endif /* !__ASSEMBLY__ */

#endif /* __UNICORE_PGTABLE_H__ */
1 change: 0 additions & 1 deletion arch/x86/include/asm/pgtable_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ extern pgd_t swapper_pg_dir[1024];
extern pgd_t initial_page_table[1024];
extern pmd_t initial_pg_pmd[];

static inline void pgtable_cache_init(void) { }
void paging_init(void);
void sync_initial_page_table(void);

Expand Down
2 changes: 0 additions & 2 deletions arch/x86/include/asm/pgtable_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,6 @@ extern void cleanup_highmap(void);
#define HAVE_ARCH_UNMAPPED_AREA
#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN

#define pgtable_cache_init() do { } while (0)

#define PAGE_AGP PAGE_KERNEL_NOCACHE
#define HAVE_PAGE_AGP 1

Expand Down
6 changes: 1 addition & 5 deletions arch/x86/mm/pgtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ static void pgd_prepopulate_user_pmd(struct mm_struct *mm,

static struct kmem_cache *pgd_cache;

void __init pgd_cache_init(void)
void __init pgtable_cache_init(void)
{
/*
* When PAE kernel is running as a Xen domain, it does not use
Expand Down Expand Up @@ -402,10 +402,6 @@ static inline void _pgd_free(pgd_t *pgd)
}
#else

void __init pgd_cache_init(void)
{
}

static inline pgd_t *_pgd_alloc(void)
{
return (pgd_t *)__get_free_pages(GFP_PGTABLE_USER,
Expand Down
1 change: 0 additions & 1 deletion arch/xtensa/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ extern void paging_init(void);
# define swapper_pg_dir NULL
static inline void paging_init(void) { }
#endif
static inline void pgtable_cache_init(void) { }

/*
* The pmd contains the kernel virtual address of the pte page.
Expand Down
2 changes: 1 addition & 1 deletion include/asm-generic/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
static inline void init_espfix_bsp(void) { }
#endif

extern void __init pgd_cache_init(void);
extern void __init pgtable_cache_init(void);

#ifndef __HAVE_ARCH_PFN_MODIFY_ALLOWED
static inline bool pfn_modify_allowed(unsigned long pfn, pgprot_t prot)
Expand Down
3 changes: 1 addition & 2 deletions init/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ void __init __weak mem_encrypt_init(void) { }

void __init __weak poking_init(void) { }

void __init __weak pgd_cache_init(void) { }
void __init __weak pgtable_cache_init(void) { }

bool initcall_debug;
core_param(initcall_debug, initcall_debug, bool, 0644);
Expand Down Expand Up @@ -565,7 +565,6 @@ static void __init mm_init(void)
init_espfix_bsp();
/* Should be run after espfix64 is set up. */
pti_init();
pgd_cache_init();
}

void __init __weak arch_call_rest_init(void)
Expand Down

0 comments on commit 782de70

Please sign in to comment.