[RFC PATCH 01/14] mm/rmap: add mm_find_pmd_raw helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Later in the series, we want to find a pmd and take different actions,
depending on if the pmd maps a thp or not.  Currently, mm_find_pmd()
returns NULL if a valid pmd maps a thp, and so we can't use it directly.

Split mm_find_pmd() into 2 parts: mm_find_pmd_raw(), which returns a
raw pmd pointer, and the logic that filters out non-present none, or
huge pmds.  mm_find_pmd_raw() can then be reused later in the series.

Signed-off-by: Zach O'Keefe <zokeefe@xxxxxxxxxx>
---
 mm/internal.h |  1 +
 mm/rmap.c     | 15 +++++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/mm/internal.h b/mm/internal.h
index 86277d90a5e2..aaea25bb9096 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -166,6 +166,7 @@ extern void reclaim_throttle(pg_data_t *pgdat, enum vmscan_throttle_state reason
 /*
  * in mm/rmap.c:
  */
+pmd_t *mm_find_pmd_raw(struct mm_struct *mm, unsigned long address);
 extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
 
 /*
diff --git a/mm/rmap.c b/mm/rmap.c
index 70375c331083..0ae99affcb27 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -758,13 +758,12 @@ unsigned long page_address_in_vma(struct page *page, struct vm_area_struct *vma)
 	return vma_address(page, vma);
 }
 
-pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address)
+pmd_t *mm_find_pmd_raw(struct mm_struct *mm, unsigned long address)
 {
 	pgd_t *pgd;
 	p4d_t *p4d;
 	pud_t *pud;
 	pmd_t *pmd = NULL;
-	pmd_t pmde;
 
 	pgd = pgd_offset(mm, address);
 	if (!pgd_present(*pgd))
@@ -779,6 +778,18 @@ pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address)
 		goto out;
 
 	pmd = pmd_offset(pud, address);
+out:
+	return pmd;
+}
+
+pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address)
+{
+	pmd_t pmde;
+	pmd_t *pmd;
+
+	pmd = mm_find_pmd_raw(mm, address);
+	if (!pmd)
+		goto out;
 	/*
 	 * Some THP functions use the sequence pmdp_huge_clear_flush(), set_pmd_at()
 	 * without holding anon_vma lock for write.  So when looking for a
-- 
2.35.1.616.g0bdcbb4464-goog





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux