From: SeongJae Park <sj@kernel.org>
To: David Hildenbrand <david@redhat.com>
Cc: SeongJae Park <sj@kernel.org>,
Usama Arif <usamaarif642@gmail.com>,
akpm@linux-foundation.org, damon@lists.linux.dev,
linux-mm@kvack.org
Subject: Re: [PATCH v3 2/2] mm/damon: introduce DAMOS filter type hugepage
Date: Tue, 21 Jan 2025 12:05:10 -0800 [thread overview]
Message-ID: <20250121200510.43645-1-sj@kernel.org> (raw)
In-Reply-To: <c2fad5c2-8929-456d-a6f9-286478b93372@redhat.com>
On Tue, 21 Jan 2025 19:39:01 +0100 David Hildenbrand <david@redhat.com> wrote:
> On 21.01.25 18:52, SeongJae Park wrote:
> > On Mon, 20 Jan 2025 21:03:05 +0100 David Hildenbrand <david@redhat.com> wrote:
> >
> >> On 20.01.25 20:58, Usama Arif wrote:
> >>>
> >>>
> >>> On 20/01/2025 19:30, SeongJae Park wrote:
> >>>> On Mon, 20 Jan 2025 20:23:20 +0100 David Hildenbrand <david@redhat.com> wrote:
> >>>>
> >>>>> On 20.01.25 20:16, SeongJae Park wrote:
> >>>>>> On Mon, 20 Jan 2025 19:57:10 +0100 David Hildenbrand <david@redhat.com> wrote:
> >>>>>>
> >>>>>>> On 20.01.25 19:19, Usama Arif wrote:
> >>>> [...]
> >>>>>>>> +#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.
> >>>>>>
> >>>>>> Nice suggestion, thank you! And we might later add more filter types for
> >>>>>> different size huge pages. What about extending this to handle more general
> >>>>>> case, though? That is, we can let the filter receives a range of the folio
> >>>>>> size to match, like DAMOS_FILTER_TYPE_ADDR does. Then, the filter could be
> >>>>>> used for any size of interest.
> >>>>>
> >>>>> That would probably be future proof: either a range or explicitly
> >>>>> specified sizes (ranges?).
> >>>>
> >>>> DAMON supports installing multiple DAMOS filters. So multiple DAMOS filters
> >>>> that each matching single range can be used for the multiple sizes or ranges
> >>>> use case.
> >>>>
> >>>>
> >>>
> >>> Does creating something like schemes/<N>/access_pattern/page_size/{min,max}
> >>> sound good? with the default value being pmd size?
> >>
> >> "page_size" might be misleading.
> >
> > Good point. I'm suggesting to add the files on another directory, and
> > apparently Usama agrees[1]. So the term "page_size" will not be used.
> >
> >> Not sure if we want to use the word
> >> "folio_size" here, so far it's more an internal detail that evolved from
> >> compound pages.
> >>
> >> "hugepage_size" would at least match /sys/kernel/mm/hugepages/ and
> >> /sys/kernel/mm/transparent_hugepage/.
> >>
> >> But if you would also support "single page" == e.g., 4K, "hugepage"
> >> would be wrong.
> >
> > Again, nice points, thank you for letting us aware of this. We could error
> > users if they try to set <=PAGE_SIZE filter range. FYI, DAMOS filters supports
> > making the filtering in/out action for not only condition-matching memory, but
> > also not-matching memory, so it will still be able to be used for filtering
> > in/out base pages.
> >
> > That said, I now think "folio_size" might be a better term that allows simple
> > implementation and flexible usages.
>
> The issue with "folio" is that it is mostly a kernel-internal name for
> how we currently manage metadata for all pages and compound pages. In
> the future, some of what we call folio today will no longer be called
> folios ... as soon as we dynamically allocate "struct folio".
Agreed. I'd suggest using "hugepage_size" or "hugepage" filter type name,
then. I have no strong preferrence between the two names. Also, to have a
flexible usage and a simple logic, let's not error users for wrong input, but
just define the filter type as "match" if the folio is "huge AND the size is in
the given range". Then we can allow users set <=PAGE_SIZE range but make it
just works as sanely expected, like below.
static bool damos_pa_filter_match(struct damos_filter *filter,
[...]
case DAMOS_FILTER_TYPE_HUGEPAGE_SIZE:
size_t sz = folio_size(folio);
if (sz <= PAGE_SIZE)
matched = false;
else
matched = filter->min <= sz && sz <= filter->max;
break;
Thanks,
SJ
[...]
next prev parent reply other threads:[~2025-01-21 20:05 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 [this message]
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
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=20250121200510.43645-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=david@redhat.com \
--cc=linux-mm@kvack.org \
--cc=usamaarif642@gmail.com \
/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