mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-05 01:54:09 +08:00
3d14f1110a
This came up when removing __ARCH_HAS_5LEVEL_HACK for ARC as code bloat. With this patch we see the following code reduction. | bloat-o-meter2 vmlinux-E-elide-p?d_clear_bad vmlinux-F-elide-pmd_free_tlb | add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-112 (-112) | function old new delta | free_pgd_range 422 310 -112 | Total: Before=4137042, After=4136930, chg -1.000000% Note that pmd folding can be tricky: In 2-level setup (where pmd is conceptually folded) most pmd routines are valid and refer to upper levels. In this patch we can, but see next patch for example where we can't Link: http://lkml.kernel.org/r/20191016162400.14796-5-vgupta@synopsys.com Signed-off-by: Vineet Gupta <vgupta@synopsys.com> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: "Aneesh Kumar K . V" <aneesh.kumar@linux.ibm.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Nick Piggin <npiggin@gmail.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Will Deacon <will@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
71 lines
1.9 KiB
C
71 lines
1.9 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _PGTABLE_NOPMD_H
|
|
#define _PGTABLE_NOPMD_H
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
#include <asm-generic/pgtable-nopud.h>
|
|
|
|
struct mm_struct;
|
|
|
|
#define __PAGETABLE_PMD_FOLDED 1
|
|
|
|
/*
|
|
* Having the pmd type consist of a pud gets the size right, and allows
|
|
* us to conceptually access the pud entry that this pmd is folded into
|
|
* without casting.
|
|
*/
|
|
typedef struct { pud_t pud; } pmd_t;
|
|
|
|
#define PMD_SHIFT PUD_SHIFT
|
|
#define PTRS_PER_PMD 1
|
|
#define PMD_SIZE (1UL << PMD_SHIFT)
|
|
#define PMD_MASK (~(PMD_SIZE-1))
|
|
|
|
/*
|
|
* The "pud_xxx()" functions here are trivial for a folded two-level
|
|
* setup: the pmd is never bad, and a pmd always exists (as it's folded
|
|
* into the pud entry)
|
|
*/
|
|
static inline int pud_none(pud_t pud) { return 0; }
|
|
static inline int pud_bad(pud_t pud) { return 0; }
|
|
static inline int pud_present(pud_t pud) { return 1; }
|
|
static inline void pud_clear(pud_t *pud) { }
|
|
#define pmd_ERROR(pmd) (pud_ERROR((pmd).pud))
|
|
|
|
#define pud_populate(mm, pmd, pte) do { } while (0)
|
|
|
|
/*
|
|
* (pmds are folded into puds so this doesn't get actually called,
|
|
* but the define is needed for a generic inline function.)
|
|
*/
|
|
#define set_pud(pudptr, pudval) set_pmd((pmd_t *)(pudptr), (pmd_t) { pudval })
|
|
|
|
static inline pmd_t * pmd_offset(pud_t * pud, unsigned long address)
|
|
{
|
|
return (pmd_t *)pud;
|
|
}
|
|
|
|
#define pmd_val(x) (pud_val((x).pud))
|
|
#define __pmd(x) ((pmd_t) { __pud(x) } )
|
|
|
|
#define pud_page(pud) (pmd_page((pmd_t){ pud }))
|
|
#define pud_page_vaddr(pud) (pmd_page_vaddr((pmd_t){ pud }))
|
|
|
|
/*
|
|
* allocating and freeing a pmd is trivial: the 1-entry pmd is
|
|
* inside the pud, so has no extra memory associated with it.
|
|
*/
|
|
#define pmd_alloc_one(mm, address) NULL
|
|
static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
|
|
{
|
|
}
|
|
#define pmd_free_tlb(tlb, x, a) do { } while (0)
|
|
|
|
#undef pmd_addr_end
|
|
#define pmd_addr_end(addr, end) (end)
|
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
#endif /* _PGTABLE_NOPMD_H */
|