Skip to contentSkip to conversation

damon: Use pmdp_get instead of drectly dereferencing pmd.

PATCH Applied Levi Yun 2 participants 3 messages Jul 27, 2023 – Jul 28, 2023

Subsystems (2)
lore
Share & tools
lore

Levi Yun

author
#0 lore raw

PATCH v2 1/1 damon: Use pmdp_get instead of drectly dereferencing pmd.

As ptep_get, Use the pmdp_get wrapper when we accessing pmdval instead of directly dereferencing pmd.

---
 mm/damon/ops-common.c |  2 +-
 mm/damon/paddr.c      |  2 +-
 mm/damon/vaddr.c      | 23 +++++++++++++++--------
 3 files changed, 17 insertions(+), 10 deletions(-)
mm/damon/ops-common.c +1 -1
index e940802a15a4..ac1c3fa80f98 100644
@@ -54,7 +54,7 @@ void damon_ptep_mkold(pte_t *pte, struct vm_area_struct *vma, unsigned long addr
 void damon_pmdp_mkold(pmd_t *pmd, struct vm_area_struct *vma, unsigned long addr)
 {
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
-	struct folio *folio = damon_get_folio(pmd_pfn(*pmd));
+	struct folio *folio = damon_get_folio(pmd_pfn(pmdp_get(pmd)));
 
 	if (!folio)
 		return;
mm/damon/paddr.c +1 -1
index 40801e38fcf0..909db25efb35 100644
@@ -94,7 +94,7 @@ static bool __damon_pa_young(struct folio *folio, struct vm_area_struct *vma,
 				mmu_notifier_test_young(vma->vm_mm, addr);
 		} else {
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
-			*accessed = pmd_young(*pvmw.pmd) ||
+			*accessed = pmd_young(pmdp_get(pvmw.pmd)) ||
 				!folio_test_idle(folio) ||
 				mmu_notifier_test_young(vma->vm_mm, addr);
 #else
mm/damon/vaddr.c +15 -8
index 2fcc9731528a..d01cc46f4bf4 100644
@@ -301,16 +301,19 @@ static int damon_mkold_pmd_entry(pmd_t *pmd, unsigned long addr,
 		unsigned long next, struct mm_walk *walk)
 {
 	pte_t *pte;
+	pmd_t pmde;
 	spinlock_t *ptl;
 
-	if (pmd_trans_huge(*pmd)) {
+	if (pmd_trans_huge(pmdp_get(pmd))) {
 		ptl = pmd_lock(walk->mm, pmd);
-		if (!pmd_present(*pmd)) {
+		pmde = pmdp_get(pmd);
+
+		if (!pmd_present(pmde)) {
 			spin_unlock(ptl);
 			return 0;
 		}
 
-		if (pmd_trans_huge(*pmd)) {
+		if (pmd_trans_huge(pmde)) {
 			damon_pmdp_mkold(pmd, walk->vma, addr);
 			spin_unlock(ptl);
 			return 0;
@@ -439,21 +442,25 @@ static int damon_young_pmd_entry(pmd_t *pmd, unsigned long addr,
 	struct damon_young_walk_private *priv = walk->private;
 
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
-	if (pmd_trans_huge(*pmd)) {
+	if (pmd_trans_huge(pmdp_get(pmd))) {
+		pmd_t pmde;
+
 		ptl = pmd_lock(walk->mm, pmd);
-		if (!pmd_present(*pmd)) {
+		pmde = pmdp_get(pmd);
+
+		if (!pmd_present(pmde)) {
 			spin_unlock(ptl);
 			return 0;
 		}
 
-		if (!pmd_trans_huge(*pmd)) {
+		if (!pmd_trans_huge(pmde)) {
 			spin_unlock(ptl);
 			goto regular_page;
 		}
-		folio = damon_get_folio(pmd_pfn(*pmd));
+		folio = damon_get_folio(pmd_pfn(pmde));
 		if (!folio)
 			goto huge_out;
-		if (pmd_young(*pmd) || !folio_test_idle(folio) ||
+		if (pmd_young(pmde) || !folio_test_idle(folio) ||
 					mmu_notifier_test_young(walk->mm,
 						addr))
 			priv->young = true;
Signature · 1 line
2.37.2
maintainer Reviewed-by on v2 1/1
#1 lore raw

Hi Levi,

Thank you for quick respin.

I still hope the subject to drop the ending period, and start the subject with lowercase, like other mm/damon/ commits.

Quoted 2 lines · On Fri, 28 Jul 2023 06:21:57 +0900 Levi Yun <[email protected]> wrote:

As ptep_get, Use the pmdp_get wrapper when we accessing pmdval instead of directly dereferencing pmd.

Based on the usual git commit message line length recommendation (72 characters), there is nothing really wrong, but putting 'instead' at the first line may look more consistent with other messages.

Quoted 3 lines

---

Since this is the good place to put additional comments not suitable for the changelog[2], it would be helpful if you could put changes of this patch that made after the v1 here, from next time.

Above comments are only my trivial and personal preferences, so I wouldn't ask you to respin, unless you really want to.

[1] https://github.com/torvalds/linux/pull/17
[2] https://docs.kernel.org/process/submitting-patches.html#the-canonical-patch-format

Thanks,
SJ

Quoted 93 lines
 mm/damon/ops-common.c |  2 +-
 mm/damon/paddr.c      |  2 +-
 mm/damon/vaddr.c      | 23 +++++++++++++++--------
 3 files changed, 17 insertions(+), 10 deletions(-)
mm/damon/ops-common.c +1 -1
index e940802a15a4..ac1c3fa80f98 100644
@@ -54,7 +54,7 @@ void damon_ptep_mkold(pte_t *pte, struct vm_area_struct *vma, unsigned long addr
 void damon_pmdp_mkold(pmd_t *pmd, struct vm_area_struct *vma, unsigned long addr)
 {
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
-	struct folio *folio = damon_get_folio(pmd_pfn(*pmd));
+	struct folio *folio = damon_get_folio(pmd_pfn(pmdp_get(pmd)));
 
 	if (!folio)
 		return;
mm/damon/paddr.c +1 -1
index 40801e38fcf0..909db25efb35 100644
@@ -94,7 +94,7 @@ static bool __damon_pa_young(struct folio *folio, struct vm_area_struct *vma,
 				mmu_notifier_test_young(vma->vm_mm, addr);
 		} else {
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
-			*accessed = pmd_young(*pvmw.pmd) ||
+			*accessed = pmd_young(pmdp_get(pvmw.pmd)) ||
 				!folio_test_idle(folio) ||
 				mmu_notifier_test_young(vma->vm_mm, addr);
 #else
mm/damon/vaddr.c +15 -8
index 2fcc9731528a..d01cc46f4bf4 100644
@@ -301,16 +301,19 @@ static int damon_mkold_pmd_entry(pmd_t *pmd, unsigned long addr,
 		unsigned long next, struct mm_walk *walk)
 {
 	pte_t *pte;
+	pmd_t pmde;
 	spinlock_t *ptl;
 
-	if (pmd_trans_huge(*pmd)) {
+	if (pmd_trans_huge(pmdp_get(pmd))) {
 		ptl = pmd_lock(walk->mm, pmd);
-		if (!pmd_present(*pmd)) {
+		pmde = pmdp_get(pmd);
+
+		if (!pmd_present(pmde)) {
 			spin_unlock(ptl);
 			return 0;
 		}
 
-		if (pmd_trans_huge(*pmd)) {
+		if (pmd_trans_huge(pmde)) {
 			damon_pmdp_mkold(pmd, walk->vma, addr);
 			spin_unlock(ptl);
 			return 0;
@@ -439,21 +442,25 @@ static int damon_young_pmd_entry(pmd_t *pmd, unsigned long addr,
 	struct damon_young_walk_private *priv = walk->private;
 
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
-	if (pmd_trans_huge(*pmd)) {
+	if (pmd_trans_huge(pmdp_get(pmd))) {
+		pmd_t pmde;
+
 		ptl = pmd_lock(walk->mm, pmd);
-		if (!pmd_present(*pmd)) {
+		pmde = pmdp_get(pmd);
+
+		if (!pmd_present(pmde)) {
 			spin_unlock(ptl);
 			return 0;
 		}
 
-		if (!pmd_trans_huge(*pmd)) {
+		if (!pmd_trans_huge(pmde)) {
 			spin_unlock(ptl);
 			goto regular_page;
 		}
-		folio = damon_get_folio(pmd_pfn(*pmd));
+		folio = damon_get_folio(pmd_pfn(pmde));
 		if (!folio)
 			goto huge_out;
-		if (pmd_young(*pmd) || !folio_test_idle(folio) ||
+		if (pmd_young(pmde) || !folio_test_idle(folio) ||
 					mmu_notifier_test_young(walk->mm,
 						addr))
 			priv->young = true;
Signature · 1 line
2.37.2
author
#2 lore raw
Quoted 9 lines · SeongJae Park

Hi Levi,

Thank you for quick respin.

I still hope the subject to drop the ending period, and start the subject with lowercase, like other mm/damon/ commits.

Sorry to bother you, I should find why the ending period inserted..

Quoted 11 lines
Quoted 2 lines

As ptep_get, Use the pmdp_get wrapper when we accessing pmdval instead of directly dereferencing pmd.

Based on the usual git commit message line length recommendation (72 characters), there is nothing really wrong, but putting 'instead' at the first line may look more consistent with other messages.

Since this is the good place to put additional comments not suitable for the changelog[2], it would be helpful if you could put changes of this patch that made after the v1 here, from next time.

Quoted 5 lines

Above comments are only my trivial and personal preferences, so I wouldn't ask you to respin, unless you really want to.

[1] https://github.com/torvalds/linux/pull/17
[2] https://docs.kernel.org/process/submitting-patches.html#the-canonical-patch-format

Thanks for letting me know some details why I missed :)

Many thanks.

--------
Sincerely,
Levi.