Skip to content

Commit

Permalink
mm: remove quicklist page table caches
Browse files Browse the repository at this point in the history
Patch series "mm: remove quicklist page table caches".

A while ago Nicholas proposed to remove quicklist page table caches [1].

I've rebased his patch on the curren upstream and switched ia64 and sh to
use generic versions of PTE allocation.

[1] https://lore.kernel.org/linux-mm/[email protected]

This patch (of 3):

Remove page table allocator "quicklists".  These have been around for a
long time, but have not got much traction in the last decade and are only
used on ia64 and sh architectures.

The numbers in the initial commit look interesting but probably don't
apply anymore.  If anybody wants to resurrect this it's in the git
history, but it's unhelpful to have this code and divergent allocator
behaviour for minor archs.

Also it might be better to instead make more general improvements to page
allocator if this is still so slow.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Nicholas Piggin <[email protected]>
Signed-off-by: Mike Rapoport <[email protected]>
Cc: Tony Luck <[email protected]>
Cc: Yoshinori Sato <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
npiggin authored and torvalds committed Sep 24, 2019
1 parent 7b167b6 commit 1322479
Show file tree
Hide file tree
Showing 39 changed files with 25 additions and 395 deletions.
2 changes: 0 additions & 2 deletions arch/alpha/include/asm/pgalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,4 @@ pmd_free(struct mm_struct *mm, pmd_t *pmd)
free_page((unsigned long)pmd);
}

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

#endif /* _ALPHA_PGALLOC_H */
1 change: 0 additions & 1 deletion arch/arc/include/asm/pgalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t ptep)

#define __pte_free_tlb(tlb, pte, addr) pte_free((tlb)->mm, pte)

#define check_pgt_cache() do { } while (0)
#define pmd_pgtable(pmd) ((pgtable_t) pmd_page_vaddr(pmd))

#endif /* _ASM_ARC_PGALLOC_H */
2 changes: 0 additions & 2 deletions arch/arm/include/asm/pgalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
#include <asm/cacheflush.h>
#include <asm/tlbflush.h>

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

#ifdef CONFIG_MMU

#define _PAGE_USER_TABLE (PMD_TYPE_TABLE | PMD_BIT4 | PMD_DOMAIN(DOMAIN_USER))
Expand Down
2 changes: 0 additions & 2 deletions arch/arm64/include/asm/pgalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

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

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

#define PGD_SIZE (PTRS_PER_PGD * sizeof(pgd_t))

#if CONFIG_PGTABLE_LEVELS > 2
Expand Down
2 changes: 0 additions & 2 deletions arch/csky/include/asm/pgalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ do { \
tlb_remove_page(tlb, pte); \
} while (0)

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

extern void pagetable_init(void);
extern void pre_mmu_init(void);
extern void pre_trap_init(void);
Expand Down
2 changes: 0 additions & 2 deletions arch/hexagon/include/asm/pgalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

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

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

extern unsigned long long kmap_generation;

/*
Expand Down
4 changes: 0 additions & 4 deletions arch/ia64/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ config 64BIT
config ZONE_DMA32
def_bool y

config QUICKLIST
bool
default y

config MMU
bool
default y
Expand Down
32 changes: 12 additions & 20 deletions arch/ia64/include/asm/pgalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@
#include <linux/mm.h>
#include <linux/page-flags.h>
#include <linux/threads.h>
#include <linux/quicklist.h>

#include <asm/mmu_context.h>

static inline pgd_t *pgd_alloc(struct mm_struct *mm)
{
return quicklist_alloc(0, GFP_KERNEL, NULL);
return (pgd_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
}

static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
{
quicklist_free(0, NULL, pgd);
free_page((unsigned long)pgd);
}

#if CONFIG_PGTABLE_LEVELS == 4
Expand All @@ -42,12 +41,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)

static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
{
return quicklist_alloc(0, GFP_KERNEL, NULL);
return (pud_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
}

static inline void pud_free(struct mm_struct *mm, pud_t *pud)
{
quicklist_free(0, NULL, pud);
free_page((unsigned long)pud);
}
#define __pud_free_tlb(tlb, pud, address) pud_free((tlb)->mm, pud)
#endif /* CONFIG_PGTABLE_LEVELS == 4 */
Expand All @@ -60,12 +59,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)

static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
{
return quicklist_alloc(0, GFP_KERNEL, NULL);
return (pmd_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
}

static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
{
quicklist_free(0, NULL, pmd);
free_page((unsigned long)pmd);
}

#define __pmd_free_tlb(tlb, pmd, address) pmd_free((tlb)->mm, pmd)
Expand All @@ -86,38 +85,31 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t * pmd_entry, pte_t * pte)
static inline pgtable_t pte_alloc_one(struct mm_struct *mm)
{
struct page *page;
void *pg;

pg = quicklist_alloc(0, GFP_KERNEL, NULL);
if (!pg)
page = alloc_page(GFP_KERNEL | __GFP_ZERO);
if (!page)
return NULL;
page = virt_to_page(pg);
if (!pgtable_page_ctor(page)) {
quicklist_free(0, NULL, pg);
__free_page(page);
return NULL;
}
return page;
}

static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
{
return quicklist_alloc(0, GFP_KERNEL, NULL);
return (pte_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
}

static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
{
pgtable_page_dtor(pte);
quicklist_free_page(0, NULL, pte);
__free_page(pte);
}

static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
{
quicklist_free(0, NULL, pte);
}

static inline void check_pgt_cache(void)
{
quicklist_trim(0, NULL, 25, 16);
free_page((unsigned long)pte);
}

#define __pte_free_tlb(tlb, pte, address) pte_free((tlb)->mm, pte)
Expand Down
2 changes: 0 additions & 2 deletions arch/m68k/include/asm/pgtable_mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,4 @@ pgprot_t pgprot_dmacoherent(pgprot_t prot);
*/
#define pgtable_cache_init() do { } while (0)

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

#endif /* _M68K_PGTABLE_H */
2 changes: 0 additions & 2 deletions arch/m68k/include/asm/pgtable_no.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,4 @@ extern void paging_init(void);

#include <asm-generic/pgtable.h>

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

#endif /* _M68KNOMMU_PGTABLE_H */
89 changes: 7 additions & 82 deletions arch/microblaze/include/asm/pgalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,83 +21,20 @@
#include <asm/cache.h>
#include <asm/pgtable.h>

#define PGDIR_ORDER 0

/*
* This is handled very differently on MicroBlaze since out page tables
* are all 0's and I want to be able to use these zero'd pages elsewhere
* as well - it gives us quite a speedup.
* -- Cort
*/
extern struct pgtable_cache_struct {
unsigned long *pgd_cache;
unsigned long *pte_cache;
unsigned long pgtable_cache_sz;
} quicklists;

#define pgd_quicklist (quicklists.pgd_cache)
#define pmd_quicklist ((unsigned long *)0)
#define pte_quicklist (quicklists.pte_cache)
#define pgtable_cache_size (quicklists.pgtable_cache_sz)

extern unsigned long *zero_cache; /* head linked list of pre-zero'd pages */
extern atomic_t zero_sz; /* # currently pre-zero'd pages */
extern atomic_t zeropage_hits; /* # zero'd pages request that we've done */
extern atomic_t zeropage_calls; /* # zero'd pages request that've been made */
extern atomic_t zerototal; /* # pages zero'd over time */

#define zero_quicklist (zero_cache)
#define zero_cache_sz (zero_sz)
#define zero_cache_calls (zeropage_calls)
#define zero_cache_hits (zeropage_hits)
#define zero_cache_total (zerototal)

/*
* return a pre-zero'd page from the list,
* return NULL if none available -- Cort
*/
extern unsigned long get_zero_page_fast(void);

extern void __bad_pte(pmd_t *pmd);

static inline pgd_t *get_pgd_slow(void)
static inline pgd_t *get_pgd(void)
{
pgd_t *ret;

ret = (pgd_t *)__get_free_pages(GFP_KERNEL, PGDIR_ORDER);
if (ret != NULL)
clear_page(ret);
return ret;
return (pgd_t *)__get_free_pages(GFP_KERNEL|__GFP_ZERO, 0);
}

static inline pgd_t *get_pgd_fast(void)
{
unsigned long *ret;

ret = pgd_quicklist;
if (ret != NULL) {
pgd_quicklist = (unsigned long *)(*ret);
ret[0] = 0;
pgtable_cache_size--;
} else
ret = (unsigned long *)get_pgd_slow();
return (pgd_t *)ret;
}

static inline void free_pgd_fast(pgd_t *pgd)
{
*(unsigned long **)pgd = pgd_quicklist;
pgd_quicklist = (unsigned long *) pgd;
pgtable_cache_size++;
}

static inline void free_pgd_slow(pgd_t *pgd)
static inline void free_pgd(pgd_t *pgd)
{
free_page((unsigned long)pgd);
}

#define pgd_free(mm, pgd) free_pgd_fast(pgd)
#define pgd_alloc(mm) get_pgd_fast()
#define pgd_free(mm, pgd) free_pgd(pgd)
#define pgd_alloc(mm) get_pgd()

#define pmd_pgtable(pmd) pmd_page(pmd)

Expand All @@ -115,29 +52,21 @@ static inline struct page *pte_alloc_one(struct mm_struct *mm)
struct page *ptepage;

#ifdef CONFIG_HIGHPTE
int flags = GFP_KERNEL | __GFP_HIGHMEM;
int flags = GFP_KERNEL | __GFP_ZERO | __GFP_HIGHMEM;
#else
int flags = GFP_KERNEL;
int flags = GFP_KERNEL | __GFP_ZERO;
#endif

ptepage = alloc_pages(flags, 0);
if (!ptepage)
return NULL;
clear_highpage(ptepage);
if (!pgtable_page_ctor(ptepage)) {
__free_page(ptepage);
return NULL;
}
return ptepage;
}

static inline void pte_free_fast(pte_t *pte)
{
*(unsigned long **)pte = pte_quicklist;
pte_quicklist = (unsigned long *) pte;
pgtable_cache_size++;
}

static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
{
free_page((unsigned long)pte);
Expand Down Expand Up @@ -171,10 +100,6 @@ static inline void pte_free(struct mm_struct *mm, struct page *ptepage)
#define __pmd_free_tlb(tlb, x, addr) pmd_free((tlb)->mm, x)
#define pgd_populate(mm, pmd, pte) BUG()

extern int do_check_pgt_cache(int, int);

#endif /* CONFIG_MMU */

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

#endif /* _ASM_MICROBLAZE_PGALLOC_H */
4 changes: 0 additions & 4 deletions arch/microblaze/mm/pgtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ unsigned long ioremap_base;
unsigned long ioremap_bot;
EXPORT_SYMBOL(ioremap_bot);

#ifndef CONFIG_SMP
struct pgtable_cache_struct quicklists;
#endif

static void __iomem *__ioremap(phys_addr_t addr, unsigned long size,
unsigned long flags)
{
Expand Down
2 changes: 0 additions & 2 deletions arch/mips/include/asm/pgalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)

#endif /* __PAGETABLE_PUD_FOLDED */

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

extern void pagetable_init(void);

#endif /* _ASM_PGALLOC_H */
2 changes: 0 additions & 2 deletions arch/nds32/include/asm/pgalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
extern pgd_t *pgd_alloc(struct mm_struct *mm);
extern void pgd_free(struct mm_struct *mm, pgd_t * pgd);

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

static inline pgtable_t pte_alloc_one(struct mm_struct *mm)
{
pgtable_t pte;
Expand Down
2 changes: 0 additions & 2 deletions arch/nios2/include/asm/pgalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,4 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
tlb_remove_page((tlb), (pte)); \
} while (0)

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

#endif /* _ASM_NIOS2_PGALLOC_H */
2 changes: 0 additions & 2 deletions arch/openrisc/include/asm/pgalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,4 @@ do { \

#define pmd_pgtable(pmd) pmd_page(pmd)

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

#endif
2 changes: 0 additions & 2 deletions arch/parisc/include/asm/pgalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,4 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte)
pmd_populate_kernel(mm, pmd, page_address(pte_page))
#define pmd_pgtable(pmd) pmd_page(pmd)

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

#endif
2 changes: 0 additions & 2 deletions arch/powerpc/include/asm/pgalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage)
extern struct kmem_cache *pgtable_cache[];
#define PGT_CACHE(shift) pgtable_cache[shift]

static inline void check_pgt_cache(void) { }

#ifdef CONFIG_PPC_BOOK3S
#include <asm/book3s/pgalloc.h>
#else
Expand Down
4 changes: 0 additions & 4 deletions arch/riscv/include/asm/pgalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,4 @@ do { \
tlb_remove_page((tlb), pte); \
} while (0)

static inline void check_pgt_cache(void)
{
}

#endif /* _ASM_RISCV_PGALLOC_H */
1 change: 0 additions & 1 deletion arch/s390/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -1686,7 +1686,6 @@ extern void s390_reset_cmma(struct mm_struct *mm);
* No page table caches to initialise
*/
static inline void pgtable_cache_init(void) { }
static inline void check_pgt_cache(void) { }

#include <asm-generic/pgtable.h>

Expand Down
Loading

0 comments on commit 1322479

Please sign in to comment.