Add folio_mk_pte()
Subsystems (31)
Matthew Wilcox (Oracle)
reviewerv2 cover Add folio_mk_pte()
Today if you have a folio and want to create a PTE that points to the first page in it, you have to convert from a folio to a page. That's zero-cost today but will be more expensive in the future.
I didn't want to add folio_mk_pte() to each architecture, and I didn't want to lose any optimisations that architectures have from their own implementation of mk_pte(). Fortunately, most architectures have by now turned their mk_pte() into a fairly bland variant of pfn_pte(), but s390 has a special optimisation that needs to be moved into generic code in the first patch.
At the end of this patch set, we have mk_pte() and folio_mk_pte() in mm.h and each architecture only has to implement pfn_pte(). We've also eliminated mk_huge_pte(), mk_huge_pmd() and mk_pmd().
Matthew Wilcox (Oracle) (11):
mm: Set the pte dirty if the folio is already dirty
mm: Introduce a common definition of mk_pte()
sparc32: Remove custom definition of mk_pte()
x86: Remove custom definition of mk_pte()
um: Remove custom definition of mk_pte()
mm: Make mk_pte() definition unconditional
mm: Add folio_mk_pte()
hugetlb: Simplify make_huge_pte()
mm: Remove mk_huge_pte()
mm: Add folio_mk_pmd()
arch: Remove mk_pmd()
arch/alpha/include/asm/pgtable.h | 7 ---- arch/arc/include/asm/hugepage.h | 2 - arch/arc/include/asm/pgtable-levels.h | 2 - arch/arm/include/asm/pgtable-3level.h | 1 - arch/arm/include/asm/pgtable.h | 1 - arch/arm64/include/asm/pgtable.h | 7 ---- arch/csky/include/asm/pgtable.h | 5 --- arch/hexagon/include/asm/pgtable.h | 3 -- arch/loongarch/include/asm/pgtable.h | 7 ---- arch/loongarch/mm/pgtable.c | 9 ----- arch/m68k/include/asm/mcf_pgtable.h | 6 --- arch/m68k/include/asm/motorola_pgtable.h | 6 --- arch/m68k/include/asm/sun3_pgtable.h | 6 --- arch/microblaze/include/asm/pgtable.h | 8 ---- arch/mips/include/asm/pgtable.h | 9 ----- arch/mips/mm/pgtable-32.c | 10 ----- arch/mips/mm/pgtable-64.c | 9 ----- arch/nios2/include/asm/pgtable.h | 6 --- arch/openrisc/include/asm/pgtable.h | 2 - arch/parisc/include/asm/pgtable.h | 6 --- arch/powerpc/include/asm/book3s/64/pgtable.h | 1 - arch/powerpc/include/asm/pgtable.h | 3 +- arch/powerpc/mm/book3s64/pgtable.c | 5 --- arch/riscv/include/asm/pgtable-64.h | 2 - arch/riscv/include/asm/pgtable.h | 2 - arch/s390/include/asm/pgtable.h | 11 ------ arch/sh/include/asm/pgtable_32.h | 8 ---- arch/sparc/include/asm/pgtable_32.h | 15 +++----- arch/sparc/include/asm/pgtable_64.h | 2 - arch/um/include/asm/pgtable-2level.h | 1 - arch/um/include/asm/pgtable-4level.h | 9 ----- arch/um/include/asm/pgtable.h | 18 ++++----- arch/x86/include/asm/pgtable.h | 21 ++--------- arch/xtensa/include/asm/pgtable.h | 6 --- fs/dax.c | 3 +- include/asm-generic/hugetlb.h | 5 --- include/linux/huge_mm.h | 2 - include/linux/mm.h | 39 ++++++++++++++++++++ mm/debug_vm_pgtable.c | 18 +++------ mm/huge_memory.c | 11 +++--- mm/hugetlb.c | 18 ++++----- mm/khugepaged.c | 2 +- mm/memory.c | 10 +++-- mm/userfaultfd.c | 2 +- 44 files changed, 83 insertions(+), 243 deletions(-)
Signature · 1 line
2.47.2
Matthew Wilcox (Oracle)
reviewerPATCH v2 1/11 mm: Set the pte dirty if the folio is already dirty
If the first access to a folio is a read that is then followed by a write, we can save a page fault. s390 implemented this in their mk_pte() in commit abf09bed3cce ("s390/mm: implement software dirty bits"), but other architectures can also benefit from this.
--- arch/s390/include/asm/pgtable.h | 7 +------ mm/memory.c | 2 ++ 2 files changed, 3 insertions(+), 6 deletions(-)
arch/s390/include/asm/pgtable.h +1 -6
@@ -1450,12 +1450,7 @@ static inline pte_t mk_pte_phys(unsigned long physpage, pgprot_t pgprot)static inline pte_t mk_pte (struct page *page,pgprot_t pgprot) { -unsigned long physpage =page_to_phys (page); -pte_t __pte =mk_pte_phys (physpage, pgprot); - -if (pte_write (__pte) &&PageDirty (page)) - __pte =pte_mkdirty (__pte); -return __pte; +return mk_pte_phys (page_to_phys (page), pgprot); }#define pgd_index (address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
mm/memory.c +2 -0
@@ -5245,6 +5245,8 @@ void set_pte_range(struct vm_fault *vmf, struct folio *folio,if (write) entry =maybe_mkwrite (pte_mkdirty (entry), vma); +else if (pte_write (entry) &&folio_test_dirty (folio)) + entry =pte_mkdirty (entry);if (unlikely (vmf_orig_pte_uffd_wp (vmf))) entry =pte_mkuffd_wp (entry);/* copy-on-write page */
Signature · 1 line
2.47.2
Matthew Wilcox (Oracle)
reviewerPATCH v2 2/11 mm: Introduce a common definition of mk_pte()
In reply to Matthew Wilcox (Oracle)Most architectures simply call pfn_pte(). Centralise that as the normal definition and remove the definition of mk_pte() from the architectures which have either that exact definition or something similar.
--- arch/alpha/include/asm/pgtable.h | 7 ------- arch/arc/include/asm/pgtable-levels.h | 1 - arch/arm/include/asm/pgtable.h | 1 - arch/arm64/include/asm/pgtable.h | 6 ------ arch/csky/include/asm/pgtable.h | 5 ----- arch/hexagon/include/asm/pgtable.h | 3 --- arch/loongarch/include/asm/pgtable.h | 6 ------ arch/m68k/include/asm/mcf_pgtable.h | 6 ------ arch/m68k/include/asm/motorola_pgtable.h | 6 ------ arch/m68k/include/asm/sun3_pgtable.h | 6 ------ arch/microblaze/include/asm/pgtable.h | 8 -------- arch/mips/include/asm/pgtable.h | 6 ------ arch/nios2/include/asm/pgtable.h | 6 ------ arch/openrisc/include/asm/pgtable.h | 2 -- arch/parisc/include/asm/pgtable.h | 6 ------ arch/powerpc/include/asm/pgtable.h | 3 +-- arch/riscv/include/asm/pgtable.h | 2 -- arch/s390/include/asm/pgtable.h | 5 ----- arch/sh/include/asm/pgtable_32.h | 8 -------- arch/sparc/include/asm/pgtable_64.h | 1 - arch/xtensa/include/asm/pgtable.h | 6 ------ include/linux/mm.h | 9 +++++++++ 22 files changed, 10 insertions(+), 99 deletions(-)
arch/alpha/include/asm/pgtable.h +0 -7
@@ -192,13 +192,6 @@ extern unsigned long __zero_page(void);#define pte_pfn (pte) (pte_val(pte) >> PFN_PTE_SHIFT)#define pte_page (pte) pfn_to_page(pte_pfn(pte)) -#define mk_pte (page, pgprot) \ -({ \ - pte_t pte; \ - \ - pte_val(pte) = (page_to_pfn(page) << 32) | pgprot_val(pgprot); \ - pte; \ -})extern inline pte_t pfn_pte (unsigned long physpfn,pgprot_t pgprot) {pte_t pte;pte_val (pte) = (PHYS_TWIDDLE (physpfn) <<32 ) |pgprot_val (pgprot);return pte; }
arch/arc/include/asm/pgtable-levels.h +0 -1
@@ -177,7 +177,6 @@#define set_pte (ptep, pte) ((*(ptep)) = (pte))#define pte_pfn (pte) (pte_val(pte) >> PAGE_SHIFT)#define pfn_pte (pfn, prot) __pte(__pfn_to_phys(pfn) | pgprot_val(prot)) -#define mk_pte (page, prot) pfn_pte(page_to_pfn(page), prot)#ifdef CONFIG_ISA_ARCV2 #define pmd_leaf (x) (pmd_val(x) & _PAGE_HW_SZ)
arch/arm/include/asm/pgtable.h +0 -1
@@ -168,7 +168,6 @@ static inline pte_t *pmd_page_vaddr(pmd_t pmd)#define pfn_pte (pfn,prot) __pte(__pfn_to_phys(pfn) | pgprot_val(prot))#define pte_page (pte) pfn_to_page(pte_pfn(pte)) -#define mk_pte (page,prot) pfn_pte(page_to_pfn(page), prot)#define pte_clear (mm,addr,ptep) set_pte_ext(ptep, __pte(0), 0)
arch/arm64/include/asm/pgtable.h +0 -6
@@ -818,12 +818,6 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)/* use ONLY for statically allocated translation tables */ #define pte_offset_kimg (dir,addr) ((pte_t *)__phys_to_kimg(pte_offset_phys((dir), (addr)))) -/* -* Conversion functions: convert a page and protection to a page entry, -* and a page entry and page directory to the page they refer to. -*/ -#define mk_pte (page,prot) pfn_pte(page_to_pfn(page),prot) -#if CONFIG_PGTABLE_LEVELS >2 #define pmd_ERROR (e) \
arch/csky/include/asm/pgtable.h +0 -5
@@ -249,11 +249,6 @@ static inline pgprot_t pgprot_writecombine(pgprot_t _prot)return __pgprot (prot); } -/* -* Conversion functions: convert a page and protection to a page entry, -* and a page entry and page directory to the page they refer to. -*/ -#define mk_pte (page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))static inline pte_t pte_modify (pte_t pte,pgprot_t newprot) { return __pte((pte_val(pte) & _PAGE_CHG_MASK) |
arch/hexagon/include/asm/pgtable.h +0 -3
@@ -238,9 +238,6 @@ static inline int pte_present(pte_t pte)return pte_val (pte) & _PAGE_PRESENT; } -/* mk_pte - make a PTE out of a page pointer and protection bits */ -#define mk_pte (page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) -/* pte_page - returns a page (frame pointer/descriptor?) based on a PTE */ #define pte_page (x) pfn_to_page(pte_pfn(x))
arch/loongarch/include/asm/pgtable.h +0 -6
@@ -426,12 +426,6 @@ static inline unsigned long pte_accessible(struct mm_struct *mm, pte_t a)return false; } -/* -* Conversion functions: convert a page and protection to a page entry, -* and a page entry and page directory to the page they refer to. -*/ -#define mk_pte (page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) -static inline pte_t pte_modify (pte_t pte,pgprot_t newprot) { return __pte((pte_val(pte) & _PAGE_CHG_MASK) |
arch/m68k/include/asm/mcf_pgtable.h +0 -6
@@ -96,12 +96,6 @@#define pmd_pgtable (pmd) pfn_to_virt(pmd_val(pmd) >> PAGE_SHIFT) -/* -* Conversion functions: convert a page and protection to a page entry, -* and a page entry and page directory to the page they refer to. -*/ -#define mk_pte (page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) -static inline pte_t pte_modify (pte_t pte,pgprot_t newprot) {pte_val (pte) = (pte_val (pte) &CF_PAGE_CHG_MASK ) |pgprot_val (newprot);
arch/m68k/include/asm/motorola_pgtable.h +0 -6
@@ -81,12 +81,6 @@ extern unsigned long mm_cachebits;#define pmd_pgtable (pmd) ((pgtable_t)pmd_page_vaddr(pmd)) -/* -* Conversion functions: convert a page and protection to a page entry, -* and a page entry and page directory to the page they refer to. -*/ -#define mk_pte (page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) -static inline pte_t pte_modify (pte_t pte,pgprot_t newprot) {pte_val (pte) = (pte_val (pte) & _PAGE_CHG_MASK) |pgprot_val (newprot);
arch/m68k/include/asm/sun3_pgtable.h +0 -6
@@ -76,12 +76,6 @@#ifndef __ASSEMBLY__ -/* -* Conversion functions: convert a page and protection to a page entry, -* and a page entry and page directory to the page they refer to. -*/ -#define mk_pte (page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) -static inline pte_t pte_modify (pte_t pte,pgprot_t newprot) {pte_val (pte) = (pte_val (pte) &SUN3_PAGE_CHG_MASK ) |pgprot_val (newprot);
arch/microblaze/include/asm/pgtable.h +0 -8
@@ -285,14 +285,6 @@ static inline pte_t mk_pte_phys(phys_addr_t physpage, pgprot_t pgprot)return pte; } -#define mk_pte (page, pgprot) \ -({ \ - pte_t pte; \ - pte_val(pte) = (((page - mem_map) << PAGE_SHIFT) + memory_start) | \ - pgprot_val(pgprot); \ - pte; \ -}) -static inline pte_t pte_modify (pte_t pte,pgprot_t newprot) {pte_val (pte) = (pte_val (pte) & _PAGE_CHG_MASK) |pgprot_val (newprot);
arch/mips/include/asm/pgtable.h +0 -6
@@ -504,12 +504,6 @@ static inline int ptep_set_access_flags(struct vm_area_struct *vma,return true; } -/* -* Conversion functions: convert a page and protection to a page entry, -* and a page entry and page directory to the page they refer to. -*/ -#define mk_pte (page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) -#if defined(CONFIG_XPA )static inline pte_t pte_modify (pte_t pte,pgprot_t newprot) {
arch/nios2/include/asm/pgtable.h +0 -6
@@ -217,12 +217,6 @@ static inline void pte_clear(struct mm_struct *mm,set_pte (ptep, null); } -/* -* Conversion functions: convert a page and protection to a page entry, -* and a page entry and page directory to the page they refer to. -*/ -#define mk_pte (page, prot) (pfn_pte(page_to_pfn(page), prot)) -/* * Conversion functions: convert a page and protection to a page entry, * and a page entry and page directory to the page they refer to.
arch/openrisc/include/asm/pgtable.h +0 -2
@@ -299,8 +299,6 @@ static inline pte_t __mk_pte(void *page, pgprot_t pgprot)return pte; } -#define mk_pte (page, pgprot) __mk_pte(page_address(page), (pgprot)) -#define mk_pte_phys (physpage, pgprot) \ ({ \ pte_t __pte; \
arch/parisc/include/asm/pgtable.h +0 -6
@@ -338,10 +338,6 @@ static inline pte_t pte_mkspecial(pte_t pte) { pte_val(pte) |= _PAGE_SPECIAL; re#endif -/* -* Conversion functions: convert a page and protection to a page entry, -* and a page entry and page directory to the page they refer to. -*/ #define __mk_pte (addr,pgprot) \ ({ \ pte_t __pte; \
@@ -351,8 +347,6 @@ static inline pte_t pte_mkspecial(pte_t pte) { pte_val(pte) |= _PAGE_SPECIAL; re __pte; \ }) -#define mk_pte (page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) -static inline pte_t pfn_pte (unsigned long pfn,pgprot_t pgprot) {pte_t pte;
arch/powerpc/include/asm/pgtable.h +1 -2
@@ -53,9 +53,8 @@ void set_ptes(struct mm_struct *mm, unsigned long addr, pte_t *ptep,#define MAX_PTRS_PER_PGD PTRS_PER_PGD#endif -/* Keep these as a macros to avoid include dependency mess */ +/* Keep this as a macro to avoid include dependency mess */ #define pte_page (x) pfn_to_page(pte_pfn(x)) -#define mk_pte (page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))static inline unsigned long pte_pfn (pte_t pte) {
arch/riscv/include/asm/pgtable.h +0 -2
@@ -339,8 +339,6 @@ static inline pte_t pfn_pte(unsigned long pfn, pgprot_t prot)return __pte ((pfn << _PAGE_PFN_SHIFT) | prot_val); } -#define mk_pte (page, prot) pfn_pte(page_to_pfn(page), prot) -static inline int pte_present (pte_t pte) {return (pte_val (pte) & (_PAGE_PRESENT | _PAGE_PROT_NONE));
arch/s390/include/asm/pgtable.h +0 -5
@@ -1448,11 +1448,6 @@ static inline pte_t mk_pte_phys(unsigned long physpage, pgprot_t pgprot)return pte_mkyoung (__pte); } -static inline pte_t mk_pte (struct page *page,pgprot_t pgprot) -{ -return mk_pte_phys (page_to_phys (page), pgprot); -} -#define pgd_index (address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))#define p4d_index (address) (((address) >> P4D_SHIFT) & (PTRS_PER_P4D-1))#define pud_index (address) (((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1))
arch/sh/include/asm/pgtable_32.h +0 -8
@@ -380,14 +380,6 @@ PTE_BIT_FUNC(low, mkspecial, |= _PAGE_SPECIAL);#define pgprot_noncached pgprot_writecombine -/* -* Conversion functions: convert a page and protection to a page entry, -* and a page entry and page directory to the page they refer to. -* -* extern pte_t mk_pte(struct page *page, pgprot_t pgprot) -*/ -#define mk_pte (page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) -static inline pte_t pte_modify (pte_t pte,pgprot_t newprot) { pte.pte_low &= _PAGE_CHG_MASK;
arch/sparc/include/asm/pgtable_64.h +0 -1
@@ -225,7 +225,6 @@ static inline pte_t pfn_pte(unsigned long pfn, pgprot_t prot)BUILD_BUG_ON (_PAGE_SZBITS_4U !=0UL || _PAGE_SZBITS_4V !=0UL );return __pte (paddr |pgprot_val (prot)); } -#define mk_pte (page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))#ifdef CONFIG_TRANSPARENT_HUGEPAGE static inline pmd_t pfn_pmd (unsigned long page_nr,pgprot_t pgprot)
arch/xtensa/include/asm/pgtable.h +0 -6
@@ -269,17 +269,11 @@ static inline pte_t pte_mkwrite_novma(pte_t pte) ((__pgprot ((pgprot_val (prot) & ~_PAGE_CA_MASK) | \ _PAGE_CA_BYPASS))) -/* -* Conversion functions: convert a page and protection to a page entry, -* and a page entry and page directory to the page they refer to. - */ -#define PFN_PTE_SHIFT PAGE_SHIFT#define pte_pfn (pte) (pte_val(pte) >> PAGE_SHIFT)#define pte_same (a,b) (pte_val(a) == pte_val(b))#define pte_page (x) pfn_to_page(pte_pfn(x))#define pfn_pte (pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) -#define mk_pte (page, prot) pfn_pte(page_to_pfn(page), prot)static inline pte_t pte_modify (pte_t pte,pgprot_t newprot) {
include/linux/mm.h +9 -0
@@ -1987,6 +1987,15 @@ static inline struct folio *pfn_folio(unsigned long pfn)return page_folio (pfn_to_page (pfn)); } +#ifndef mk_pte +#ifdef CONFIG_MMU +static inline pte_t mk_pte (struct page *page,pgprot_t pgprot) +{ +return pfn_pte (page_to_pfn (page), pgprot); +} +#endif +#endif +static inline bool folio_has_pincount (const struct folio *folio) {if (IS_ENABLED (CONFIG_64BIT ))
Signature · 1 line
2.47.2
Matthew Wilcox (Oracle)
reviewerPATCH v2 3/11 sparc32: Remove custom definition of mk_pte()
In reply to Matthew Wilcox (Oracle)Instead of defining pfn_pte() in terms of mk_pte(), make pfn_pte() the base implementation. That lets us use the generic definition of mk_pte().
--- arch/sparc/include/asm/pgtable_32.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
arch/sparc/include/asm/pgtable_32.h +5 -10
@@ -255,7 +255,11 @@ static inline pte_t pte_mkyoung(pte_t pte) }#define PFN_PTE_SHIFT (PAGE_SHIFT - 4) -#define pfn_pte (pfn, prot) mk_pte(pfn_to_page(pfn), prot) + +static inline pte_t pfn_pte (unsigned long pfn,pgprot_t pgprot) +{ +return __pte ((pfn <<PFN_PTE_SHIFT ) |pgprot_val (pgprot)); +}static inline unsigned long pte_pfn (pte_t pte) {
@@ -272,15 +276,6 @@ static inline unsigned long pte_pfn(pte_t pte)#define pte_page (pte) pfn_to_page(pte_pfn(pte)) -/* -* Conversion functions: convert a page and protection to a page entry, -* and a page entry and page directory to the page they refer to. -*/ -static inline pte_t mk_pte (struct page *page,pgprot_t pgprot) -{ -return __pte ((page_to_pfn (page) << (PAGE_SHIFT -4 )) |pgprot_val (pgprot)); -} -static inline pte_t mk_pte_phys (unsigned long page,pgprot_t pgprot) {return __pte (((page) >>4 ) |pgprot_val (pgprot));
Signature · 1 line
2.47.2
Matthew Wilcox (Oracle)
reviewerPATCH v2 4/11 x86: Remove custom definition of mk_pte()
In reply to Matthew Wilcox (Oracle)Move the shadow stack check to pfn_pte() which lets us use the common definition of mk_pte().
--- arch/x86/include/asm/pgtable.h | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-)
arch/x86/include/asm/pgtable.h +3 -16
@@ -784,6 +784,9 @@ static inline pgprotval_t check_pgprot(pgprot_t pgprot)static inline pte_t pfn_pte (unsigned long page_nr,pgprot_t pgprot) {phys_addr_t pfn = (phys_addr_t )page_nr <<PAGE_SHIFT ; +/* This bit combination is used to mark shadow stacks */ +WARN_ON_ONCE ((pgprot_val (pgprot) & (_PAGE_DIRTY | _PAGE_RW)) == + _PAGE_DIRTY); pfn ^=protnone_mask (pgprot_val (pgprot)); pfn &=PTE_PFN_MASK ;return __pte (pfn |check_pgprot (pgprot));
@@ -1080,22 +1083,6 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)*/ #define pmd_page (pmd) pfn_to_page(pmd_pfn(pmd)) -/* -* Conversion functions: convert a page and protection to a page entry, -* and a page entry and page directory to the page they refer to. -* -* (Currently stuck as a macro because of indirect forward reference -* to linux/mm.h:page_to_nid()) -*/ -#define mk_pte (page, pgprot) \ -({ \ - pgprot_t __pgprot = pgprot; \ - \ - WARN_ON_ONCE((pgprot_val(__pgprot) & (_PAGE_DIRTY | _PAGE_RW)) == \ - _PAGE_DIRTY); \ - pfn_pte(page_to_pfn(page), __pgprot); \ -}) -static inline int pmd_bad (pmd_t pmd) { return (pmd_flags(pmd) & ~(_PAGE_USER | _PAGE_ACCESSED)) !=
Signature · 1 line
2.47.2
Matthew Wilcox (Oracle)
reviewerPATCH v2 5/11 um: Remove custom definition of mk_pte()
In reply to Matthew Wilcox (Oracle)Move the pfn_pte() definitions from the 2level and 4level files to the generic pgtable.h and delete the custom definition of mk_pte() so that we use the central definition.
--- arch/um/include/asm/pgtable-2level.h | 1 - arch/um/include/asm/pgtable-4level.h | 9 --------- arch/um/include/asm/pgtable.h | 18 ++++++++---------- 3 files changed, 8 insertions(+), 20 deletions(-)
arch/um/include/asm/pgtable-2level.h +0 -1
@@ -37,7 +37,6 @@ static inline void pgd_mkuptodate(pgd_t pgd) { }#define set_pmd (pmdptr, pmdval) (*(pmdptr) = (pmdval))#define pte_pfn (x) phys_to_pfn(pte_val(x)) -#define pfn_pte (pfn, prot) __pte(pfn_to_phys(pfn) | pgprot_val(prot))#define pfn_pmd (pfn, prot) __pmd(pfn_to_phys(pfn) | pgprot_val(prot))#endif
arch/um/include/asm/pgtable-4level.h +0 -9
@@ -102,15 +102,6 @@ static inline unsigned long pte_pfn(pte_t pte)return phys_to_pfn (pte_val (pte)); } -static inline pte_t pfn_pte (unsigned long page_nr,pgprot_t pgprot) -{ -pte_t pte; -phys_t phys =pfn_to_phys (page_nr); - -pte_set_val (pte, phys, pgprot); -return pte; -} -static inline pmd_t pfn_pmd (unsigned long page_nr,pgprot_t pgprot) {return __pmd ((page_nr <<PAGE_SHIFT ) |pgprot_val (pgprot));
arch/um/include/asm/pgtable.h +8 -10
@@ -260,19 +260,17 @@ static inline int pte_same(pte_t pte_a, pte_t pte_b)return !((pte_val (pte_a) ^pte_val (pte_b)) & ~_PAGE_NEEDSYNC); } -/* -* Conversion functions: convert a page and protection to a page entry, -* and a page entry and page directory to the page they refer to. -*/ -#define __virt_to_page (virt) phys_to_page(__pa(virt))#define virt_to_page (addr) __virt_to_page((const unsigned long) addr) -#define mk_pte (page, pgprot) \ - ({ pte_t pte; \ - \ - pte_set_val(pte, page_to_phys(page), (pgprot)); \ - pte;}) +static inline pte_t pfn_pte (unsigned long pfn,pgprot_t pgprot) +{ +pte_t pte; + +pte_set_val (pte,pfn_to_phys (pfn), pgprot); + +return pte; +}static inline pte_t pte_modify (pte_t pte,pgprot_t newprot) {
Signature · 1 line
2.47.2
Matthew Wilcox (Oracle)
reviewerPATCH v2 6/11 mm: Make mk_pte() definition unconditional
In reply to Matthew Wilcox (Oracle)All architectures now use the common mk_pte() definition, so we can remove the condition.
--- include/linux/mm.h | 2 -- 1 file changed, 2 deletions(-)
include/linux/mm.h +0 -2
@@ -1987,14 +1987,12 @@ static inline struct folio *pfn_folio(unsigned long pfn)return page_folio (pfn_to_page (pfn)); } -#ifndef mk_pte#ifdef CONFIG_MMU static inline pte_t mk_pte (struct page *page,pgprot_t pgprot) {return pfn_pte (page_to_pfn (page), pgprot); }#endif -#endif static inline bool folio_has_pincount (const struct folio *folio) {
Signature · 1 line
2.47.2
Matthew Wilcox (Oracle)
reviewerPATCH v2 7/11 mm: Add folio_mk_pte()
In reply to Matthew Wilcox (Oracle)Removes a cast from folio to page in four callers of mk_pte().
--- include/linux/mm.h | 15 +++++++++++++++ mm/memory.c | 6 +++--- mm/userfaultfd.c | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-)
include/linux/mm.h +15 -0
@@ -1992,6 +1992,21 @@ static inline pte_t mk_pte(struct page *page, pgprot_t pgprot) {return pfn_pte (page_to_pfn (page), pgprot); } + +/** +* folio_mk_pte - Create a PTE for this folio +* @folio: The folio to create a PTE for +* @pgprot: The page protection bits to use +* +* Create a page table entry for the first page of this folio. +* This is suitable for passing to set_ptes(). +* +* Return: A page table entry suitable for mapping this folio. +*/ +static inline pte_t folio_mk_pte (struct folio *folio,pgprot_t pgprot) +{ +return pfn_pte (folio_pfn (folio), pgprot); +}#endif static inline bool folio_has_pincount (const struct folio *folio)
mm/memory.c +3 -3
@@ -929,7 +929,7 @@ copy_present_page(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma rss[MM_ANONPAGES ]++;/* All done, just insert the new page copy in the child */ - pte =mk_pte (&new_folio->page, dst_vma->vm_page_prot); + pte =folio_mk_pte (new_folio, dst_vma->vm_page_prot); pte =maybe_mkwrite (pte_mkdirty (pte), dst_vma);if (userfaultfd_pte_wp (dst_vma,ptep_get (src_pte)))/* Uffd-wp needs to be delivered to dest pte as well */
@@ -3523,7 +3523,7 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf)inc_mm_counter (mm,MM_ANONPAGES ); }flush_cache_page (vma, vmf->address,pte_pfn (vmf->orig_pte)); - entry =mk_pte (&new_folio->page, vma->vm_page_prot); + entry =folio_mk_pte (new_folio, vma->vm_page_prot); entry =pte_sw_mkyoung (entry);if (unlikely (unshare)) {if (pte_soft_dirty (vmf->orig_pte))
@@ -5013,7 +5013,7 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf)*/ __folio_mark_uptodate (folio); - entry =mk_pte (&folio->page, vma->vm_page_prot); + entry =folio_mk_pte (folio, vma->vm_page_prot); entry =pte_sw_mkyoung (entry);if (vma->vm_flags &VM_WRITE ) entry =pte_mkwrite (pte_mkdirty (entry), vma);
mm/userfaultfd.c +1 -1
@@ -1063,7 +1063,7 @@ static int move_present_pte(struct mm_struct *mm,folio_move_anon_rmap (src_folio, dst_vma); src_folio->index =linear_page_index (dst_vma, dst_addr); - orig_dst_pte =mk_pte (&src_folio->page, dst_vma->vm_page_prot); + orig_dst_pte =folio_mk_pte (src_folio, dst_vma->vm_page_prot);/* Follow mremap() behavior and treat the entry dirty after the move */ orig_dst_pte =pte_mkwrite (pte_mkdirty (orig_dst_pte), dst_vma);
Signature · 1 line
2.47.2
Matthew Wilcox (Oracle)
reviewerPATCH v2 8/11 hugetlb: Simplify make_huge_pte()
In reply to Matthew Wilcox (Oracle)mk_huge_pte() is a bad API. Despite its name, it creates a normal PTE which is later transformed into a huge PTE by arch_make_huge_pte(). So replace the page argument with a folio argument and call folio_mk_pte() instead. Then, because we now know this is a regular PTE rather than a huge one, use pte_mkdirty() instead of huge_pte_mkdirty() (and similar functions).
--- mm/hugetlb.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
mm/hugetlb.c +8 -10
@@ -5441,18 +5441,16 @@ const struct vm_operations_struct hugetlb_vm_ops = { .pagesize = hugetlb_vm_op_pagesize, }; -static pte_t make_huge_pte (struct vm_area_struct *vma,struct page *page, +static pte_t make_huge_pte (struct vm_area_struct *vma,struct folio *folio,bool try_mkwrite) { -pte_t entry; +pte_t entry =folio_mk_pte (folio, vma->vm_page_prot);unsigned int shift =huge_page_shift (hstate_vma (vma));if (try_mkwrite && (vma->vm_flags &VM_WRITE )) { - entry =huge_pte_mkwrite (huge_pte_mkdirty (mk_huge_pte (page, - vma->vm_page_prot))); + entry =pte_mkwrite_novma (pte_mkdirty (entry)); }else { - entry =huge_pte_wrprotect (mk_huge_pte (page, - vma->vm_page_prot)); + entry =pte_wrprotect (entry); } entry =pte_mkyoung (entry); entry =arch_make_huge_pte (entry, shift, vma->vm_flags);
@@ -5507,7 +5505,7 @@ static void hugetlb_install_folio(struct vm_area_struct *vma, pte_t *ptep, unsigned long addr, struct folio *new_folio, pte_t old, unsigned long sz) { - pte_t newpte = make_huge_pte(vma, &new_folio->page, true); + pte_t newpte = make_huge_pte(vma, new_folio, true);__folio_mark_uptodate (new_folio);hugetlb_add_new_anon_rmap (new_folio, vma, addr);
@@ -6257,7 +6255,7 @@ static vm_fault_t hugetlb_wp(struct folio *pagecache_folio,spin_lock (vmf->ptl); vmf->pte =hugetlb_walk (vma, vmf->address,huge_page_size (h));if (likely (vmf->pte &&pte_same (huge_ptep_get (mm, vmf->address, vmf->pte), pte))) { -pte_t newpte =make_huge_pte (vma, &new_folio->page, !unshare); +pte_t newpte =make_huge_pte (vma, new_folio, !unshare);/* Break COW or unshare */ huge_ptep_clear_flush (vma, vmf->address, vmf->pte);
@@ -6537,7 +6535,7 @@ static vm_fault_t hugetlb_no_page(struct address_space *mapping,hugetlb_add_new_anon_rmap (folio, vma, vmf->address); elsehugetlb_add_file_rmap (folio ); - new_pte =make_huge_pte (vma, &folio->page, vma->vm_flags &VM_SHARED ); + new_pte =make_huge_pte (vma, folio, vma->vm_flags &VM_SHARED );/* * If this pte was previously wr-protected, keep it wr-protected even * if populated.
@@ -7022,7 +7020,7 @@ int hugetlb_mfill_atomic_pte(pte_t *dst_pte,* For either: (1) CONTINUE on a non-shared VMA, or (2) UFFDIO_COPY * with wp flag set, don't set pte write bit. */ - _dst_pte =make_huge_pte (dst_vma, &folio->page, + _dst_pte =make_huge_pte (dst_vma, folio, !wp_enabled && !(is_continue && !vm_shared));/* * Always mark UFFDIO_COPY page dirty; note that this may not be
Signature · 1 line
2.47.2
Matthew Wilcox (Oracle)
reviewerPATCH v2 9/11 mm: Remove mk_huge_pte()
In reply to Matthew Wilcox (Oracle)The only remaining user of mk_huge_pte() is the debug code, so remove the API and replace its use with pfn_pte() which lets us remove the conversion to a page first. We should always call arch_make_huge_pte() to turn this PTE into a huge PTE before operating on it with huge_pte_mkdirty() etc.
--- include/asm-generic/hugetlb.h | 5 ----- mm/debug_vm_pgtable.c | 18 +++++------------- 2 files changed, 5 insertions(+), 18 deletions(-)
include/asm-generic/hugetlb.h +0 -5
@@ -5,11 +5,6 @@#include <linux/swap.h> #include <linux/swapops.h> -static inline pte_t mk_huge_pte (struct page *page,pgprot_t pgprot) -{ -return mk_pte (page, pgprot); -} -static inline unsigned long huge_pte_write (pte_t pte) {return pte_write (pte);
mm/debug_vm_pgtable.c +5 -13
@@ -910,26 +910,18 @@ static void __init swap_migration_tests(struct pgtable_debug_args *args)#ifdef CONFIG_HUGETLB_PAGE static void __init hugetlb_basic_tests (struct pgtable_debug_args *args) { -struct page *page;pte_t pte;pr_debug ("Validating HugeTLB basic\n" ); -/* -* Accessing the page associated with the pfn is safe here, -* as it was previously derived from a real kernel symbol. -*/ - page =pfn_to_page (args->fixed_pmd_pfn); - pte =mk_huge_pte (page, args->page_prot); + pte =pfn_pte (args->fixed_pmd_pfn, args->page_prot); + pte =arch_make_huge_pte (pte,PMD_SHIFT ,VM_ACCESS_FLAGS ); +#ifdef CONFIG_ARCH_WANT_GENERAL_HUGETLB +WARN_ON (!pte_huge (pte)); +#endif WARN_ON (!huge_pte_dirty (huge_pte_mkdirty (pte)));WARN_ON (!huge_pte_write (huge_pte_mkwrite (huge_pte_wrprotect (pte))));WARN_ON (huge_pte_write (huge_pte_wrprotect (huge_pte_mkwrite (pte)))); - -#ifdef CONFIG_ARCH_WANT_GENERAL_HUGETLB - pte =pfn_pte (args->fixed_pmd_pfn, args->page_prot); - -WARN_ON (!pte_huge (arch_make_huge_pte (pte,PMD_SHIFT ,VM_ACCESS_FLAGS ))); -#endif /* CONFIG_ARCH_WANT_GENERAL_HUGETLB */ }#else /* !CONFIG_HUGETLB_PAGE */ static void __init hugetlb_basic_tests (struct pgtable_debug_args *args) { }
Signature · 1 line
2.47.2
Matthew Wilcox (Oracle)
reviewerPATCH v2 10/11 mm: Add folio_mk_pmd()
In reply to Matthew Wilcox (Oracle)Removes five conversions from folio to page. Also removes both callers of mk_pmd() that aren't part of mk_huge_pmd(), getting us a step closer to removing the confusion between mk_pmd(), mk_huge_pmd() and pmd_mkhuge().
--- fs/dax.c | 3 +-- include/linux/mm.h | 17 +++++++++++++++++ mm/huge_memory.c | 11 +++++------ mm/khugepaged.c | 2 +- mm/memory.c | 2 +- 5 files changed, 25 insertions(+), 10 deletions(-)
fs/dax.c +1 -2
@@ -1421,8 +1421,7 @@ static vm_fault_t dax_pmd_load_hole(struct xa_state *xas, struct vm_fault *vmf,pgtable_trans_huge_deposit (vma->vm_mm, vmf->pmd, pgtable);mm_inc_nr_ptes (vma->vm_mm); } - pmd_entry =mk_pmd (&zero_folio->page, vmf->vma->vm_page_prot); - pmd_entry =pmd_mkhuge (pmd_entry); + pmd_entry =folio_mk_pmd (zero_folio, vmf->vma->vm_page_prot);set_pmd_at (vmf->vma->vm_mm, pmd_addr, vmf->pmd, pmd_entry);spin_unlock (ptl);trace_dax_pmd_load_hole (inode, vmf, zero_folio, *entry);
include/linux/mm.h +17 -0
@@ -2007,7 +2007,24 @@ static inline pte_t folio_mk_pte(struct folio *folio, pgprot_t pgprot) {return pfn_pte (folio_pfn (folio), pgprot); } + +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +/** +* folio_mk_pmd - Create a PMD for this folio +* @folio: The folio to create a PMD for +* @pgprot: The page protection bits to use +* +* Create a page table entry for the first page of this folio. +* This is suitable for passing to set_pmd_at(). +* +* Return: A page table entry suitable for mapping this folio. +*/ +static inline pmd_t folio_mk_pmd (struct folio *folio,pgprot_t pgprot) +{ +return pmd_mkhuge (pfn_pmd (folio_pfn (folio), pgprot)); +}#endif +#endif /* CONFIG_MMU */ static inline bool folio_has_pincount (const struct folio *folio) {
mm/huge_memory.c +5 -6
@@ -1203,7 +1203,7 @@ static void map_anon_folio_pmd(struct folio *folio, pmd_t *pmd, {pmd_t entry; - entry =mk_huge_pmd (&folio->page, vma->vm_page_prot); + entry =folio_mk_pmd (folio, vma->vm_page_prot); entry =maybe_pmd_mkwrite (pmd_mkdirty (entry), vma);folio_add_new_anon_rmap (folio, vma, haddr,RMAP_EXCLUSIVE );folio_add_lru_vma (folio, vma);
@@ -1309,8 +1309,7 @@ static void set_huge_zero_folio(pgtable_t pgtable, struct mm_struct *mm, struct folio *zero_folio) {pmd_t entry; - entry =mk_pmd (&zero_folio->page, vma->vm_page_prot); - entry =pmd_mkhuge (entry); + entry =folio_mk_pmd (zero_folio, vma->vm_page_prot);pgtable_trans_huge_deposit (mm, pmd, pgtable);set_pmd_at (mm, haddr, pmd, entry);mm_inc_nr_ptes (mm);
@@ -2653,12 +2652,12 @@ int move_pages_huge_pmd(struct mm_struct *mm, pmd_t *dst_pmd, pmd_t *src_pmd, pmfolio_move_anon_rmap (src_folio, dst_vma); src_folio->index =linear_page_index (dst_vma, dst_addr); - _dst_pmd =mk_huge_pmd (&src_folio->page, dst_vma->vm_page_prot); + _dst_pmd =folio_mk_pmd (src_folio, dst_vma->vm_page_prot);/* Follow mremap() behavior and treat the entry dirty after the move */ _dst_pmd =pmd_mkwrite (pmd_mkdirty (_dst_pmd), dst_vma); }else { src_pmdval =pmdp_huge_clear_flush (src_vma, src_addr, src_pmd); - _dst_pmd =mk_huge_pmd (src_page, dst_vma->vm_page_prot); + _dst_pmd =folio_mk_pmd (src_folio, dst_vma->vm_page_prot); }set_pmd_at (mm, dst_addr, dst_pmd, _dst_pmd);
@@ -4675,7 +4674,7 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) entry =pmd_to_swp_entry (*pvmw->pmd);folio_get (folio); - pmde =mk_huge_pmd (new,READ_ONCE (vma->vm_page_prot)); + pmde =folio_mk_pmd (folio,READ_ONCE (vma->vm_page_prot));if (pmd_swp_soft_dirty (*pvmw->pmd)) pmde =pmd_mksoft_dirty (pmde);if (is_writable_migration_entry (entry))
mm/khugepaged.c +1 -1
@@ -1239,7 +1239,7 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address,__folio_mark_uptodate (folio); pgtable =pmd_pgtable (_pmd); - _pmd =mk_huge_pmd (&folio->page, vma->vm_page_prot); + _pmd =folio_mk_pmd (folio, vma->vm_page_prot); _pmd =maybe_pmd_mkwrite (pmd_mkdirty (_pmd), vma);spin_lock (pmd_ptl);
mm/memory.c +1 -1
@@ -5188,7 +5188,7 @@ vm_fault_t do_set_pmd(struct vm_fault *vmf, struct page *page)flush_icache_pages (vma, page,HPAGE_PMD_NR ); - entry =mk_huge_pmd (page, vma->vm_page_prot); + entry =folio_mk_pmd (folio, vma->vm_page_prot);if (write) entry =maybe_pmd_mkwrite (pmd_mkdirty (entry), vma);
Signature · 1 line
2.47.2
Zi Yan
reviewerRe: [PATCH v2 10/11] mm: Add folio_mk_pmd()
Quoted 4 lines · Matthew Wilcox (Oracle)
Removes five conversions from folio to page. Also removes both callers of
mk_pmd()that aren't part ofmk_huge_pmd(), getting us a step closer to removing the confusion betweenmk_pmd(),mk_huge_pmd()andpmd_mkhuge().
Quoted 9 lines
Signed-off-by Matthew Wilcox (Oracle) <[email protected]>--- fs/dax.c | 3 +-- include/linux/mm.h | 17 +++++++++++++++++ mm/huge_memory.c | 11 +++++------ mm/khugepaged.c | 2 +- mm/memory.c | 2 +- 5 files changed, 25 insertions(+), 10 deletions(-)
The changes look good to me. Reviewed-by: Zi Yan <[email protected]>
Signature · 2 lines
Best Regards, Yan, Zi
Matthew Wilcox (Oracle)
reviewerPATCH v2 11/11 arch: Remove mk_pmd()
In reply to Matthew Wilcox (Oracle)There are now no callers of mk_huge_pmd() and mk_pmd(). Remove them.
--- arch/arc/include/asm/hugepage.h | 2 -- arch/arc/include/asm/pgtable-levels.h | 1 - arch/arm/include/asm/pgtable-3level.h | 1 - arch/arm64/include/asm/pgtable.h | 1 - arch/loongarch/include/asm/pgtable.h | 1 - arch/loongarch/mm/pgtable.c | 9 --------- arch/mips/include/asm/pgtable.h | 3 --- arch/mips/mm/pgtable-32.c | 10 ---------- arch/mips/mm/pgtable-64.c | 9 --------- arch/powerpc/include/asm/book3s/64/pgtable.h | 1 - arch/powerpc/mm/book3s64/pgtable.c | 5 ----- arch/riscv/include/asm/pgtable-64.h | 2 -- arch/s390/include/asm/pgtable.h | 1 - arch/sparc/include/asm/pgtable_64.h | 1 - arch/x86/include/asm/pgtable.h | 2 -- include/linux/huge_mm.h | 2 -- 16 files changed, 51 deletions(-)
arch/arc/include/asm/hugepage.h +0 -2
@@ -40,8 +40,6 @@ static inline pmd_t pte_pmd(pte_t pte)#define pmd_young (pmd) pte_young(pmd_pte(pmd))#define pmd_dirty (pmd) pte_dirty(pmd_pte(pmd)) -#define mk_pmd (page, prot) pte_pmd(mk_pte(page, prot)) -#define pmd_trans_huge (pmd) (pmd_val(pmd) & _PAGE_HW_SZ)#define pfn_pmd (pfn, prot) (__pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot)))
arch/arc/include/asm/pgtable-levels.h +0 -1
@@ -142,7 +142,6 @@#define pmd_pfn (pmd) ((pmd_val(pmd) & PMD_MASK) >> PAGE_SHIFT)#define pfn_pmd (pfn,prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) -#define mk_pmd (page,prot) pfn_pmd(page_to_pfn(page),prot)#endif
arch/arm/include/asm/pgtable-3level.h +0 -1
@@ -209,7 +209,6 @@ PMD_BIT_FUNC(mkyoung, |= PMD_SECT_AF);#define pmd_pfn (pmd) (((pmd_val(pmd) & PMD_MASK) & PHYS_MASK) >> PAGE_SHIFT)#define pfn_pmd (pfn,prot) (__pmd(((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot))) -#define mk_pmd (page,prot) pfn_pmd(page_to_pfn(page),prot)/* No hardware dirty/accessed bits -- generic_pmdp_establish() fits */ #define pmdp_establish generic_pmdp_establish
arch/arm64/include/asm/pgtable.h +0 -1
@@ -609,7 +609,6 @@ static inline pmd_t pmd_mkspecial(pmd_t pmd)#define __phys_to_pmd_val (phys) __phys_to_pte_val(phys)#define pmd_pfn (pmd) ((__pmd_to_phys(pmd) & PMD_MASK) >> PAGE_SHIFT)#define pfn_pmd (pfn,prot) __pmd(__phys_to_pmd_val((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot)) -#define mk_pmd (page,prot) pfn_pmd(page_to_pfn(page),prot)#define pud_young (pud) pte_young(pud_pte(pud))#define pud_mkyoung (pud) pte_pud(pte_mkyoung(pud_pte(pud)))
arch/loongarch/include/asm/pgtable.h +0 -1
@@ -255,7 +255,6 @@ static inline void pmd_clear(pmd_t *pmdp)#define pmd_page_vaddr (pmd) pmd_val(pmd) -extern pmd_t mk_pmd (struct page *page,pgprot_t prot);extern void set_pmd_at (struct mm_struct *mm,unsigned long addr,pmd_t *pmdp,pmd_t pmd);#define pte_page (x) pfn_to_page(pte_pfn(x))
arch/loongarch/mm/pgtable.c +0 -9
@@ -135,15 +135,6 @@ void kernel_pte_init(void *addr) }while (p != end); } -pmd_t mk_pmd (struct page *page,pgprot_t prot) -{ -pmd_t pmd; - -pmd_val (pmd) = (page_to_pfn (page) <<PFN_PTE_SHIFT ) |pgprot_val (prot); - -return pmd; -} -void set_pmd_at (struct mm_struct *mm,unsigned long addr,pmd_t *pmdp,pmd_t pmd) {
arch/mips/include/asm/pgtable.h +0 -3
@@ -713,9 +713,6 @@ static inline pmd_t pmd_clear_soft_dirty(pmd_t pmd)#endif /* CONFIG_HAVE_ARCH_SOFT_DIRTY */ -/* Extern to avoid header file madness */ -extern pmd_t mk_pmd (struct page *page,pgprot_t prot); -static inline pmd_t pmd_modify (pmd_t pmd,pgprot_t newprot) { pmd_val(pmd) = (pmd_val(pmd) & (_PAGE_CHG_MASK | _PAGE_HUGE)) |
arch/mips/mm/pgtable-32.c +0 -10
@@ -31,16 +31,6 @@ void pgd_init(void *addr) }#if defined(CONFIG_TRANSPARENT_HUGEPAGE ) -pmd_t mk_pmd (struct page *page,pgprot_t prot) -{ -pmd_t pmd; - -pmd_val (pmd) = (page_to_pfn (page) <<PFN_PTE_SHIFT ) |pgprot_val (prot); - -return pmd; -} - -void set_pmd_at (struct mm_struct *mm,unsigned long addr,pmd_t *pmdp,pmd_t pmd) {
arch/mips/mm/pgtable-64.c +0 -9
@@ -90,15 +90,6 @@ void pud_init(void *addr)#endif #ifdef CONFIG_TRANSPARENT_HUGEPAGE -pmd_t mk_pmd (struct page *page,pgprot_t prot) -{ -pmd_t pmd; - -pmd_val (pmd) = (page_to_pfn (page) <<PFN_PTE_SHIFT ) |pgprot_val (prot); - -return pmd; -} -void set_pmd_at (struct mm_struct *mm,unsigned long addr,pmd_t *pmdp,pmd_t pmd) {
arch/powerpc/include/asm/book3s/64/pgtable.h +0 -1
@@ -1096,7 +1096,6 @@ static inline bool pmd_access_permitted(pmd_t pmd, bool write)#ifdef CONFIG_TRANSPARENT_HUGEPAGE extern pmd_t pfn_pmd (unsigned long pfn,pgprot_t pgprot);extern pud_t pfn_pud (unsigned long pfn,pgprot_t pgprot); -extern pmd_t mk_pmd (struct page *page,pgprot_t pgprot);extern pmd_t pmd_modify (pmd_t pmd,pgprot_t newprot);extern pud_t pud_modify (pud_t pud,pgprot_t newprot); extern void set_pmd_at(struct mm_struct *mm, unsigned long addr,
arch/powerpc/mm/book3s64/pgtable.c +0 -5
@@ -270,11 +270,6 @@ pud_t pfn_pud(unsigned long pfn, pgprot_t pgprot)return __pud_mkhuge (pud_set_protbits (__pud (pudv), pgprot)); } -pmd_t mk_pmd (struct page *page,pgprot_t pgprot) -{ -return pfn_pmd (page_to_pfn (page), pgprot); -} -pmd_t pmd_modify (pmd_t pmd,pgprot_t newprot) {unsigned long pmdv;
arch/riscv/include/asm/pgtable-64.h +0 -2
@@ -262,8 +262,6 @@ static inline unsigned long _pmd_pfn(pmd_t pmd)return __page_val_to_pfn (pmd_val (pmd)); } -#define mk_pmd (page, prot) pfn_pmd(page_to_pfn(page), prot) -#define pmd_ERROR (e) \ pr_err("%s:%d: bad pmd %016lx.\n", __FILE__, __LINE__, pmd_val(e))
arch/s390/include/asm/pgtable.h +0 -1
@@ -1869,7 +1869,6 @@ static inline pmd_t pmdp_collapse_flush(struct vm_area_struct *vma,#define pmdp_collapse_flush pmdp_collapse_flush#define pfn_pmd (pfn, pgprot) mk_pmd_phys(((pfn) << PAGE_SHIFT), (pgprot)) -#define mk_pmd (page, pgprot) pfn_pmd(page_to_pfn(page), (pgprot))static inline int pmd_trans_huge (pmd_t pmd) {
arch/sparc/include/asm/pgtable_64.h +0 -1
@@ -233,7 +233,6 @@ static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot) return __pmd(pte_val(pte)); } -#define mk_pmd (page, pgprot) pfn_pmd(page_to_pfn(page), (pgprot))#endif /* This one can be done with two shifts. */
arch/x86/include/asm/pgtable.h +0 -2
@@ -1347,8 +1347,6 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm,#define flush_tlb_fix_spurious_fault (vma, address, ptep) do { } while (0) -#define mk_pmd (page, pgprot) pfn_pmd(page_to_pfn(page), (pgprot)) -#define __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS extern int pmdp_set_access_flags(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp,
include/linux/huge_mm.h +0 -2
@@ -495,8 +495,6 @@ static inline bool is_huge_zero_pmd(pmd_t pmd)struct folio *mm_get_huge_zero_folio (struct mm_struct *mm);void mm_put_huge_zero_folio (struct mm_struct *mm); -#define mk_huge_pmd (page, prot) pmd_mkhuge(mk_pmd(page, prot)) -static inline bool thp_migration_supported (void ) {return IS_ENABLED (CONFIG_ARCH_ENABLE_THP_MIGRATION );
Signature · 1 line
2.47.2