2021-02-11 00:09:36

by Mike Kravetz

[permalink] [raw]
Subject: [RFC PATCH 3/5] mm proc/task_mmu.c: add soft dirty pte checks for hugetlb

Pagemap was only using the vma flag PM_SOFT_DIRTY for hugetlb vmas.
This is insufficient. Check the individual pte entries.

Signed-off-by: Mike Kravetz <[email protected]>
---
fs/proc/task_mmu.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 602e3a52884d..829b35016aaa 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -1507,6 +1507,10 @@ static int pagemap_hugetlb_range(pte_t *ptep, unsigned long hmask,
flags |= PM_SOFT_DIRTY;

pte = huge_ptep_get(ptep);
+
+ if (huge_pte_soft_dirty(pte))
+ flags |= PM_SOFT_DIRTY;
+
if (pte_present(pte)) {
struct page *page = pte_page(pte);

--
2.29.2


2021-02-17 22:32:09

by Peter Xu

[permalink] [raw]
Subject: Re: [RFC PATCH 3/5] mm proc/task_mmu.c: add soft dirty pte checks for hugetlb

On Wed, Feb 10, 2021 at 04:03:20PM -0800, Mike Kravetz wrote:
> Pagemap was only using the vma flag PM_SOFT_DIRTY for hugetlb vmas.
> This is insufficient. Check the individual pte entries.
>
> Signed-off-by: Mike Kravetz <[email protected]>
> ---
> fs/proc/task_mmu.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> index 602e3a52884d..829b35016aaa 100644
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -1507,6 +1507,10 @@ static int pagemap_hugetlb_range(pte_t *ptep, unsigned long hmask,
> flags |= PM_SOFT_DIRTY;
>
> pte = huge_ptep_get(ptep);
> +
> + if (huge_pte_soft_dirty(pte))
> + flags |= PM_SOFT_DIRTY;

Should this be put into pte_present() chunk below? Since I feel like we'd need
huge_pte_swp_soft_dirty() for !pte_present(). Say, _PAGE_SOFT_DIRTY and
_PAGE_SWP_SOFT_DIRTY can be different.

> +
> if (pte_present(pte)) {
> struct page *page = pte_page(pte);
>
> --
> 2.29.2
>

--
Peter Xu

2021-02-19 00:04:18

by Mike Kravetz

[permalink] [raw]
Subject: Re: [RFC PATCH 3/5] mm proc/task_mmu.c: add soft dirty pte checks for hugetlb

On 2/17/21 11:35 AM, Peter Xu wrote:
> On Wed, Feb 10, 2021 at 04:03:20PM -0800, Mike Kravetz wrote:
>> Pagemap was only using the vma flag PM_SOFT_DIRTY for hugetlb vmas.
>> This is insufficient. Check the individual pte entries.
>>
>> Signed-off-by: Mike Kravetz <[email protected]>
>> ---
>> fs/proc/task_mmu.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
>> index 602e3a52884d..829b35016aaa 100644
>> --- a/fs/proc/task_mmu.c
>> +++ b/fs/proc/task_mmu.c
>> @@ -1507,6 +1507,10 @@ static int pagemap_hugetlb_range(pte_t *ptep, unsigned long hmask,
>> flags |= PM_SOFT_DIRTY;
>>
>> pte = huge_ptep_get(ptep);
>> +
>> + if (huge_pte_soft_dirty(pte))
>> + flags |= PM_SOFT_DIRTY;
>
> Should this be put into pte_present() chunk below? Since I feel like we'd need
> huge_pte_swp_soft_dirty() for !pte_present(). Say, _PAGE_SOFT_DIRTY and
> _PAGE_SWP_SOFT_DIRTY can be different.
>

Yes this should be moved below, and it should check for both.

Thanks,
--
Mike Kravetz

>> +
>> if (pte_present(pte)) {
>> struct page *page = pte_page(pte);
>>
>> --
>> 2.29.2
>>
>