2022-06-20 03:21:01

by Baolin Wang

[permalink] [raw]
Subject: [PATCH] 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")
Signed-off-by: Baolin Wang <[email protected]>
---
mm/damon/vaddr.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
index 5767be72c181..d24148a8149f 100644
--- a/mm/damon/vaddr.c
+++ b/mm/damon/vaddr.c
@@ -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
--
2.27.0


2022-06-20 17:43:39

by SeongJae Park

[permalink] [raw]
Subject: Re: [PATCH] mm/damon: Use set_huge_pte_at() to make huge pte old

Hi Baolin,

On Mon, 20 Jun 2022 10:34:42 +0800 Baolin Wang <[email protected]> wrote:

> 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?

Cc: <[email protected]>

> Signed-off-by: Baolin Wang <[email protected]>

Other than that,

Reviewed-by: SeongJae Park <[email protected]>


Thanks,
SJ

> ---
> mm/damon/vaddr.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
> index 5767be72c181..d24148a8149f 100644
> --- a/mm/damon/vaddr.c
> +++ b/mm/damon/vaddr.c
> @@ -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
> --
> 2.27.0

2022-06-21 08:55:06

by Baolin Wang

[permalink] [raw]
Subject: Re: [PATCH] mm/damon: Use set_huge_pte_at() to make huge pte old

Hi SeongJae,

On 6/21/2022 1:27 AM, SeongJae Park wrote:
> Hi Baolin,
>
> On Mon, 20 Jun 2022 10:34:42 +0800 Baolin Wang <[email protected]> wrote:
>
>> 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?
>
> Cc: <[email protected]>

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

>
>> Signed-off-by: Baolin Wang <[email protected]>
>
> Other than that,
>
> Reviewed-by: SeongJae Park <[email protected]>

Thanks.

2022-06-21 23:52:45

by Mike Kravetz

[permalink] [raw]
Subject: Re: [PATCH] mm/damon: Use set_huge_pte_at() to make huge pte old

On 06/20/22 10:34, Baolin Wang wrote:
> 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")
> Signed-off-by: Baolin Wang <[email protected]>

Thanks,

Acked-by: Mike Kravetz <[email protected]>
--
Mike Kravetz

> ---
> mm/damon/vaddr.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
> index 5767be72c181..d24148a8149f 100644
> --- a/mm/damon/vaddr.c
> +++ b/mm/damon/vaddr.c
> @@ -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
> --
> 2.27.0
>

2022-06-22 03:27:53

by Muchun Song

[permalink] [raw]
Subject: Re: [PATCH] mm/damon: Use set_huge_pte_at() to make huge pte old

On Mon, Jun 20, 2022 at 10:34:42AM +0800, Baolin Wang wrote:
> 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")
> Signed-off-by: Baolin Wang <[email protected]>

The changes make sense to me.

Reviewed-by: Muchun Song <[email protected]>