linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Usama Arif <usamaarif642@gmail.com>
To: David Hildenbrand <david@redhat.com>,
	sj@kernel.org, akpm@linux-foundation.org
Cc: damon@lists.linux.dev, linux-mm@kvack.org
Subject: Re: [PATCH v3 2/2] mm/damon: introduce DAMOS filter type hugepage
Date: Mon, 20 Jan 2025 19:18:17 +0000	[thread overview]
Message-ID: <f8e95ec8-f800-495d-a723-53edd0d487f5@gmail.com> (raw)
In-Reply-To: <9257fbb9-d26d-4028-896f-fb8cfad3ddad@redhat.com>



On 20/01/2025 18:57, David Hildenbrand wrote:
> On 20.01.25 19:19, Usama Arif wrote:
>> This is to gather statistics to check if memory regions of specific
>> access tempratures are backed by hugepages. This includes both THPs
>> and hugetlbfs.
>> This filter can help to observe and prove the effectivenes of
>> different schemes for shrinking/collapsing hugepages.
>>
>> Signed-off-by: Usama Arif <usamaarif642@gmail.com>
>> ---
>> v2 -> v3:
>> - expose hugepage via sysfs even if the kernel is
>>    built without hugepage support. DAMON will just
>>    just return 0. (SJ Park)
>>
>> v1 -> v2:
>> - Wrap DAMOS_FILTER_TYPE_HUGEPAGE case with
>>    CONFIG_PGTABLE_HAS_HUGE_LEAVES (SJ Park)
>> ---
>>   include/linux/damon.h    | 2 ++
>>   mm/damon/paddr.c         | 5 +++++
>>   mm/damon/sysfs-schemes.c | 1 +
>>   3 files changed, 8 insertions(+)
>>
>> diff --git a/include/linux/damon.h b/include/linux/damon.h
>> index af525252b853..1d94d7d88b36 100644
>> --- a/include/linux/damon.h
>> +++ b/include/linux/damon.h
>> @@ -326,6 +326,7 @@ struct damos_stat {
>>    * @DAMOS_FILTER_TYPE_ANON:    Anonymous pages.
>>    * @DAMOS_FILTER_TYPE_MEMCG:    Specific memcg's pages.
>>    * @DAMOS_FILTER_TYPE_YOUNG:    Recently accessed pages.
>> + * @DAMOS_FILTER_TYPE_HUGEPAGE:    Page is part of a hugepage.
>>    * @DAMOS_FILTER_TYPE_ADDR:    Address range.
>>    * @DAMOS_FILTER_TYPE_TARGET:    Data Access Monitoring target.
>>    * @NR_DAMOS_FILTER_TYPES:    Number of filter types.
>> @@ -345,6 +346,7 @@ enum damos_filter_type {
>>       DAMOS_FILTER_TYPE_ANON,
>>       DAMOS_FILTER_TYPE_MEMCG,
>>       DAMOS_FILTER_TYPE_YOUNG,
>> +    DAMOS_FILTER_TYPE_HUGEPAGE,
>>       DAMOS_FILTER_TYPE_ADDR,
>>       DAMOS_FILTER_TYPE_TARGET,
>>       NR_DAMOS_FILTER_TYPES,
>> diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c
>> index c0ccf4fade24..224308140441 100644
>> --- a/mm/damon/paddr.c
>> +++ b/mm/damon/paddr.c
>> @@ -222,6 +222,11 @@ static bool damos_pa_filter_match(struct damos_filter *filter,
>>           if (matched)
>>               damon_folio_mkold(folio);
>>           break;
>> +#if defined(CONFIG_PGTABLE_HAS_HUGE_LEAVES)
>> +    case DAMOS_FILTER_TYPE_HUGEPAGE:
>> +        matched = folio_size(folio) == HPAGE_PMD_SIZE;
> 
> 
> Can we directly embed in the name and the comments/docs that we are only talking about PMD size (both, THP and hugetlb)?
> 
> DAMOS_FILTER_TYPE_PMD_HUGEPAGE or sth. like that.
> 
> 

I always think of gigantic page as PUD size, hugepage as PMD size (and not anything smaller), mTHP as smaller than PMD :)
But I don't think thats the official term or standardized across the kernel.  

I can send a v4, or maybe Andrew could apply the diff below?

diff --git a/include/linux/damon.h b/include/linux/damon.h
index 1d94d7d88b36..261c0741dd0f 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -326,7 +326,7 @@ struct damos_stat {
  * @DAMOS_FILTER_TYPE_ANON:    Anonymous pages.
  * @DAMOS_FILTER_TYPE_MEMCG:   Specific memcg's pages.
  * @DAMOS_FILTER_TYPE_YOUNG:   Recently accessed pages.
- * @DAMOS_FILTER_TYPE_HUGEPAGE:        Page is part of a hugepage.
+ * @DAMOS_FILTER_TYPE_PMD_HUGEPAGE:    Page is part of a hugepage (THP/hugetlb).
  * @DAMOS_FILTER_TYPE_ADDR:    Address range.
  * @DAMOS_FILTER_TYPE_TARGET:  Data Access Monitoring target.
  * @NR_DAMOS_FILTER_TYPES:     Number of filter types.
@@ -346,7 +346,7 @@ enum damos_filter_type {
        DAMOS_FILTER_TYPE_ANON,
        DAMOS_FILTER_TYPE_MEMCG,
        DAMOS_FILTER_TYPE_YOUNG,
-       DAMOS_FILTER_TYPE_HUGEPAGE,
+       DAMOS_FILTER_TYPE_PMD_HUGEPAGE,
        DAMOS_FILTER_TYPE_ADDR,
        DAMOS_FILTER_TYPE_TARGET,
        NR_DAMOS_FILTER_TYPES,
diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c
index 224308140441..e374ea952308 100644
--- a/mm/damon/paddr.c
+++ b/mm/damon/paddr.c
@@ -223,7 +223,7 @@ static bool damos_pa_filter_match(struct damos_filter *filter,
                        damon_folio_mkold(folio);
                break;
 #if defined(CONFIG_PGTABLE_HAS_HUGE_LEAVES)
-       case DAMOS_FILTER_TYPE_HUGEPAGE:
+       case DAMOS_FILTER_TYPE_PMD_HUGEPAGE:
                matched = folio_size(folio) == HPAGE_PMD_SIZE;
                break;
 #endif



  parent reply	other threads:[~2025-01-20 19:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-20 18:19 [PATCH v3 1/2] mm/damon: have damon_get_folio return folio even for tail pages Usama Arif
2025-01-20 18:19 ` [PATCH v3 2/2] mm/damon: introduce DAMOS filter type hugepage Usama Arif
2025-01-20 18:33   ` SeongJae Park
2025-01-20 18:57   ` David Hildenbrand
2025-01-20 19:16     ` SeongJae Park
2025-01-20 19:23       ` David Hildenbrand
2025-01-20 19:30         ` SeongJae Park
2025-01-20 19:58           ` Usama Arif
2025-01-20 20:03             ` David Hildenbrand
2025-01-21 17:52               ` SeongJae Park
2025-01-21 18:39                 ` David Hildenbrand
2025-01-21 20:05                   ` SeongJae Park
2025-01-20 20:12             ` SeongJae Park
2025-01-20 20:26               ` Usama Arif
2025-01-20 20:48                 ` SeongJae Park
2025-01-20 19:18     ` Usama Arif [this message]
2025-01-20 19:25       ` David Hildenbrand

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=f8e95ec8-f800-495d-a723-53edd0d487f5@gmail.com \
    --to=usamaarif642@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=damon@lists.linux.dev \
    --cc=david@redhat.com \
    --cc=linux-mm@kvack.org \
    --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