Skip to contentSkip to conversation

mm/damon: Use set_huge_pte_at() to make huge pte old

PATCH Applied Baolin Wang 4 participants 5 messages Jun 20, 2022 – Jun 22, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/damon: Use set_huge_pte_at() to make huge pte old

The huge_ptep_set_access_flags() can not make the huge pte old according to the discussion [1], that means we will always mornitor the young state of the hugetlb though we stopped accessing the hugetlb, as a result DAMON will get inaccurate accessing statistics.

So changing to use set_huge_pte_at() to make the huge pte old to fix this issue.

[1] https://lore.kernel.org/all/[email protected]/

Fixes 49f4203aae06 ("mm/damon: add access checking for hugetlb pages")
---
 mm/damon/vaddr.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
mm/damon/vaddr.c +1 -2
index 5767be72c181..d24148a8149f 100644
@@ -337,8 +337,7 @@ static void damon_hugetlb_mkold(pte_t *pte, struct mm_struct *mm,
 	if (pte_young(entry)) {
 		referenced = true;
 		entry = pte_mkold(entry);
-		huge_ptep_set_access_flags(vma, addr, pte, entry,
-					   vma->vm_flags & VM_WRITE);
+		set_huge_pte_at(mm, addr, pte, entry);
 	}
 
 #ifdef CONFIG_MMU_NOTIFIER
Signature · 1 line
2.27.0
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi Baolin,

Quoted 11 lines · On Mon, 20 Jun 2022 10:34:42 +0800 Baolin Wang <[email protected]>…

The huge_ptep_set_access_flags() can not make the huge pte old according to the discussion [1], that means we will always mornitor the young state of the hugetlb though we stopped accessing the hugetlb, as a result DAMON will get inaccurate accessing statistics.

So changing to use set_huge_pte_at() to make the huge pte old to fix this issue.

[1] https://lore.kernel.org/all/[email protected]/

Fixes 49f4203aae06 ("mm/damon: add access checking for hugetlb pages")

As the commit has merged in from v5.17, I guess it would be better to do below?

Quoted 1 line

Other than that,

Thanks,
SJ

Quoted 20 lines
---
 mm/damon/vaddr.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
mm/damon/vaddr.c +1 -2
index 5767be72c181..d24148a8149f 100644
@@ -337,8 +337,7 @@ static void damon_hugetlb_mkold(pte_t *pte, struct mm_struct *mm,
 	if (pte_young(entry)) {
 		referenced = true;
 		entry = pte_mkold(entry);
-		huge_ptep_set_access_flags(vma, addr, pte, entry,
-					   vma->vm_flags & VM_WRITE);
+		set_huge_pte_at(mm, addr, pte, entry);
 	}
 
 #ifdef CONFIG_MMU_NOTIFIER
Signature · 1 line
2.27.0
#2 lore raw

Hi SeongJae,

Quoted 12 lines · SeongJae Park

Hi Baolin,

Quoted 8 lines · On Mon, 20 Jun 2022 10:34:42 +0800 Baolin Wang <[email protected]>…

The huge_ptep_set_access_flags() can not make the huge pte old according to the discussion [1], that means we will always mornitor the young state of the hugetlb though we stopped accessing the hugetlb, as a result DAMON will get inaccurate accessing statistics.

So changing to use set_huge_pte_at() to make the huge pte old to fix this issue.

Quoted 7 lines
Quoted 3 lines

[1] https://lore.kernel.org/all/[email protected]/

Fixes 49f4203aae06 ("mm/damon: add access checking for hugetlb pages")

As the commit has merged in from v5.17, I guess it would be better to do below?

Yes, thanks for reminding. Hope Andrew can help to add the stable tag when picking up this patch.

Quoted 6 lines
Quoted 2 lines

Other than that,

Thanks.

Acked-by on v1 1/1
#3 lore raw
In reply to Baolin Wang
Quoted 5 lines · Baolin Wang

The huge_ptep_set_access_flags() can not make the huge pte old according to the discussion [1], that means we will always mornitor the young state of the hugetlb though we stopped accessing the hugetlb, as a result DAMON will get inaccurate accessing statistics.

Quoted 7 lines

So changing to use set_huge_pte_at() to make the huge pte old to fix this issue.

[1] https://lore.kernel.org/all/[email protected]/

Fixes 49f4203aae06 ("mm/damon: add access checking for hugetlb pages")

Thanks,

Signature · 1 line
Mike Kravetz
Quoted 21 lines
---
 mm/damon/vaddr.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
mm/damon/vaddr.c +1 -2
index 5767be72c181..d24148a8149f 100644
@@ -337,8 +337,7 @@ static void damon_hugetlb_mkold(pte_t *pte, struct mm_struct *mm,
 	if (pte_young(entry)) {
 		referenced = true;
 		entry = pte_mkold(entry);
-		huge_ptep_set_access_flags(vma, addr, pte, entry,
-					   vma->vm_flags & VM_WRITE);
+		set_huge_pte_at(mm, addr, pte, entry);
 	}
 
 #ifdef CONFIG_MMU_NOTIFIER
Signature · 1 line
2.27.0
Reviewed-by on v1 1/1
#4 lore raw
In reply to Baolin Wang
Quoted 5 lines · Baolin Wang

The huge_ptep_set_access_flags() can not make the huge pte old according to the discussion [1], that means we will always mornitor the young state of the hugetlb though we stopped accessing the hugetlb, as a result DAMON will get inaccurate accessing statistics.

Quoted 7 lines

So changing to use set_huge_pte_at() to make the huge pte old to fix this issue.

[1] https://lore.kernel.org/all/[email protected]/

Fixes 49f4203aae06 ("mm/damon: add access checking for hugetlb pages")

The changes make sense to me.