[PATCH] inline vm_normal_page()
From: Vlastimil Babka
Date: Wed Mar 31 2021 - 09:59:15 EST
---
include/linux/mm.h | 18 +++++++++++++++++-
mm/internal.h | 2 --
mm/memory.c | 2 +-
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 3e4dc6678eb2..1df6ce4ab668 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1711,8 +1711,24 @@ struct zap_details {
pgoff_t last_index; /* Highest page->index to unmap */
};
-struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
+struct page *__vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
pte_t pte);
+extern unsigned long highest_memmap_pfn;
+static inline struct page *vm_normal_page(struct vm_area_struct *vma,
+ unsigned long addr, pte_t pte)
+{
+ unsigned long pfn;
+
+ if (IS_ENABLED(CONFIG_ARCH_HAS_PTE_SPECIAL)
+ && likely(!pte_special(pte))) {
+ pfn = pte_pfn(pte);
+ if (likely(pfn <= highest_memmap_pfn))
+ return pfn_to_page(pfn);
+ }
+
+ return __vm_normal_page(vma, addr, pte);
+}
+
struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr,
pmd_t pmd);
diff --git a/mm/internal.h b/mm/internal.h
index 547a8d7f0cbb..cca1cbc3f6fa 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -117,8 +117,6 @@ static inline bool is_page_poisoned(struct page *page)
return false;
}
-extern unsigned long highest_memmap_pfn;
-
/*
* Maximum number of reclaim retries without progress before the OOM
* killer is consider the only way forward.
diff --git a/mm/memory.c b/mm/memory.c
index 5c3b29d3af66..d801914cfce4 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -603,7 +603,7 @@ static void print_bad_pte(struct vm_area_struct *vma, unsigned long addr,
* PFNMAP mappings in order to support COWable mappings.
*
*/
-struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
+struct page *__vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
pte_t pte)
{
unsigned long pfn = pte_pfn(pte);
--
2.30.2