linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: SeongJae Park <sj@kernel.org>
Cc: akpm@linux-foundation.org, mike.kravetz@oracle.com,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] mm/damon: Add access checking for hugetlb pages
Date: Wed, 22 Dec 2021 17:32:52 +0800	[thread overview]
Message-ID: <17421c73-2124-63c2-1925-dcea5c976711@linux.alibaba.com> (raw)
In-Reply-To: <20211222091007.16495-1-sj@kernel.org>



On 12/22/2021 5:10 PM, SeongJae Park wrote:
> Hi Baolin,
> 
> 
> Basically, the code looks ok to me.  I left so trivial cosmetic nitpicks below,
> though.
> 
> On Thu, 16 Dec 2021 18:38:03 +0800 Baolin Wang <baolin.wang@linux.alibaba.com> wrote:
> 
>> The process's VMAs can be mapped by hugetlb page, but now the DAMON
>> did not implement the access checking for hugetlb pte, so we can not
>> get the actual access count like below if a process VMAs were mapped
>> by hugetlb.
>>
>> damon_aggregated: target_id=18446614368406014464
>> nr_regions=12 4194304-5476352: 0 545
>> damon_aggregated: target_id=18446614368406014464
>> nr_regions=12 140662370467840-140662372970496: 0 545
>> damon_aggregated: target_id=18446614368406014464
>> nr_regions=12 140662372970496-140662375460864: 0 545
>> damon_aggregated: target_id=18446614368406014464
>> nr_regions=12 140662375460864-140662377951232: 0 545
>> damon_aggregated: target_id=18446614368406014464
>> nr_regions=12 140662377951232-140662380449792: 0 545
>> damon_aggregated: target_id=18446614368406014464
>> nr_regions=12 140662380449792-140662382944256: 0 545
>> ......
> 
> I'd prefer indenting the program output with 4 spaces and not wrapping it.
> e.g.,
> 
>      damon_aggregated: target_id=18446614368406014464 nr_regions=12 4194304-5476352: 0 545
>      damon_aggregated: target_id=18446614368406014464 nr_regions=12 140662370467840-140662372970496: 0 545

Sure.

>>
>> Thus this patch adds hugetlb access checking support, with this patch
>> we can see below VMA mapped by hugetlb access count.
>>
>> damon_aggregated: target_id=18446613056935405824
>> nr_regions=12 140296486649856-140296489914368: 1 3
>> damon_aggregated: target_id=18446613056935405824
>> nr_regions=12 140296489914368-140296492978176: 1 3
>> damon_aggregated: target_id=18446613056935405824
>> nr_regions=12 140296492978176-140296495439872: 1 3
>> damon_aggregated: target_id=18446613056935405824
>> nr_regions=12 140296495439872-140296498311168: 1 3
>> damon_aggregated: target_id=18446613056935405824
>> nr_regions=12 140296498311168-140296501198848: 1 3
>> damon_aggregated: target_id=18446613056935405824
>> nr_regions=12 140296501198848-140296504320000: 1 3
>> damon_aggregated: target_id=18446613056935405824
>> nr_regions=12 140296504320000-140296507568128: 1 2
>> ......
> 
> ditto.

Sure.

>> +static int damon_mkold_hugetlb_entry(pte_t *pte, unsigned long hmask,
>> +				     unsigned long addr, unsigned long end,
>> +				     struct mm_walk *walk)
>> +{
>> +	struct hstate *h = hstate_vma(walk->vma);
>> +	spinlock_t *ptl;
>> +	pte_t entry;
>> +
>> +	ptl = huge_pte_lock(h, walk->mm, pte);
>> +	entry = huge_ptep_get(pte);
>> +	if (!pte_present(entry))
>> +		goto out;
>> +
>> +	damon_hugetlb_mkold(pte, walk->mm, walk->vma, addr);
>> +
>> +out:
>> +	spin_unlock(ptl);
>> +	return 0;
>> +}
>> +#else
>> +#define damon_mkold_hugetlb_entry NULL
>> +#endif
> 
> Could we append a comment saying this #endif is for #ifdef CONFIG_HUGETLB_PAGE,
> like below?
> 
>      #endif	/* CONFIG_HUGETLB_PAGE */

Sure.

>> +#ifdef CONFIG_HUGETLB_PAGE
>> +static int damon_young_hugetlb_entry(pte_t *pte, unsigned long hmask,
>> +				     unsigned long addr, unsigned long end,
>> +				     struct mm_walk *walk)
>> +{
>> +	struct damon_young_walk_private *priv = walk->private;
>> +	struct hstate *h = hstate_vma(walk->vma);
>> +	struct page *page;
>> +	spinlock_t *ptl;
>> +	pte_t entry;
>> +
>> +	ptl = huge_pte_lock(h, walk->mm, pte);
>> +	entry = huge_ptep_get(pte);
>> +	if (!pte_present(entry))
>> +		goto out;
>> +
>> +	page = pte_page(entry);
>> +	if (!page)
>> +		goto out;
>> +
>> +	get_page(page);
>> +
>> +	if (pte_young(entry) || !page_is_idle(page) ||
>> +	    mmu_notifier_test_young(walk->mm, addr)) {
>> +		*priv->page_sz = huge_page_size(h);
>> +		priv->young = true;
>> +	}
>> +
>> +	put_page(page);
>> +
>> +out:
>> +	spin_unlock(ptl);
>> +	return 0;
>> +}
>> +#else
>> +#define damon_young_hugetlb_entry NULL
>> +#endif
> 
> ditto.

Sure.

But I saw Andrew had applied this version into his branch.

Andrew, would you like me to send a new version? or an increment patch 
to fix the coding style issue? Thanks.


      reply	other threads:[~2021-12-22  9:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-16 10:38 Baolin Wang
2021-12-22  9:10 ` SeongJae Park
2021-12-22  9:32   ` Baolin Wang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17421c73-2124-63c2-1925-dcea5c976711@linux.alibaba.com \
    --to=baolin.wang@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.com \
    --cc=sj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox