From: Gutierrez Asier <gutierrez.asier@huawei-partners.com>
To: SeongJae Park <sj@kernel.org>
Cc: <artem.kuzin@huawei.com>, <stepanov.anatoly@huawei.com>,
<wangkefeng.wang@huawei.com>, <yanquanmin1@huawei.com>,
<zuoze1@huawei.com>, <damon@lists.linux.dev>,
<akpm@linux-foundation.org>, <linux-mm@kvack.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1] mm/damon: guard THP-specific DAMOS actions with CONFIG_TRANSPARENT_HUGEPAGE
Date: Mon, 16 Mar 2026 10:03:43 +0300 [thread overview]
Message-ID: <66131775-180b-4b9f-b7ce-61a3e077b6e6@huawei-partners.com> (raw)
In-Reply-To: <20260314165156.86647-1-sj@kernel.org>
Hi SJ,
On 3/14/2026 7:51 PM, SeongJae Park wrote:
> Hello Asier,
>
> On Sat, 14 Mar 2026 09:38:12 +0000 <gutierrez.asier@huawei-partners.com> wrote:
>
>> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
>>
>> MADV_HUGEPAGE and MADV_NOHUGEPAGE are guarded and they are not
>> available when compiling the kernel without TRANSPARENT_HUGEPAGE
>> option. Therefore, DAMOS_HUGEPAGE and DAMOS_NOHUGEPAGE shouldn't be
>> available to the user either.
>
> That makes many sense to me. But, I'd prefer having ifdef as minimum as
> possible because ifdef increases amount of code that I need to maintain per
> different configurations. I understand use of ifdef can make the resulting
> kernel image more optimized. But, unless the benefit of optimization is
> obviously big enough, I'd prefer simplicity of the code in general.
>
> When TRASPARENT_HUGEPAGE is off, DAMOS_[NO]HUGEPAGE will just silently fail. I
> think that's not a bad user experience if the silently fail is kindly informed.
> How about updating document for that, but keeping the code as is?
>
>>
>> Signed-off-by: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
>> ---
>> Documentation/mm/damon/design.rst | 6 ++++--
>> include/linux/damon.h | 2 ++
>> mm/damon/sysfs-schemes.c | 2 ++
>> mm/damon/vaddr.c | 2 ++
>> 4 files changed, 10 insertions(+), 2 deletions(-)
>>
>> diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
>> index 29fff20b3c2a..207219ee10d4 100644
>> --- a/Documentation/mm/damon/design.rst
>> +++ b/Documentation/mm/damon/design.rst
>> @@ -460,9 +460,11 @@ that supports each action are as below.
>> - ``pageout``: Reclaim the region.
>> Supported by ``vaddr``, ``fvaddr`` and ``paddr`` operations set.
>> - ``hugepage``: Call ``madvise()`` for the region with ``MADV_HUGEPAGE``.
>> - Supported by ``vaddr`` and ``fvaddr`` operations set.
>> + Supported by ``vaddr`` and ``fvaddr`` operations set when
>> + TRANSPARENT_HUGEPAGE is enabled.
>> - ``nohugepage``: Call ``madvise()`` for the region with ``MADV_NOHUGEPAGE``.
>> - Supported by ``vaddr`` and ``fvaddr`` operations set.
>> + Supported by ``vaddr`` and ``fvaddr`` operations set when
>> + TRANSPARENT_HUGEPAGE is enabled.
>
> I like the above change. I'd suggest make it just describe the current
> behavior in a better way. E.g., "Supported by vaddr and fvaddr. When
> CONFIG_TRANSPARENT_HUGEPAG is disabled, however, the application of the action
> will just fail always.
>
>> - ``lru_prio``: Prioritize the region on its LRU lists.
>> Supported by ``paddr`` operations set.
>> - ``lru_deprio``: Deprioritize the region on its LRU lists.
>> diff --git a/include/linux/damon.h b/include/linux/damon.h
>> index 3a441fbca170..b3fcbe84b5d7 100644
>> --- a/include/linux/damon.h
>> +++ b/include/linux/damon.h
>> @@ -138,8 +138,10 @@ enum damos_action {
>> DAMOS_WILLNEED,
>> DAMOS_COLD,
>> DAMOS_PAGEOUT,
>> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>> DAMOS_HUGEPAGE,
>> DAMOS_NOHUGEPAGE,
>> +#endif
>> DAMOS_LRU_PRIO,
>> DAMOS_LRU_DEPRIO,
>> DAMOS_MIGRATE_HOT,
>
> Also, sashiko.dev commented [1] some conrens as below:
>
> '''
> Does adding this #ifdef shift the integer values of subsequent actions like
> DAMOS_STAT when CONFIG_TRANSPARENT_HUGEPAGE is disabled?
> The kernel selftest tools/testing/selftests/damon/sysfs.py uses drgn to read
> the internal damos->action enum value and expects hardcoded integer values
> (such as 'stat': 9).
> Additionally, modifying enum layouts based on kernel configuration can break
> BPF and drgn tracing tools that rely on stable DWARF/BTF types.
> '''
>
That's a good catch, I didn't think about it.
> There is no selftest using DAMOS action that defined after DAMOS_HUGEPAGE, so
> this change should be _safe_. But the code does have a hard-coded mapping of
> DAMOS action to value, in sysfs.py file under the DAMON selftests directory.
> Maintaining it correctly with future tests for different configuration may be
> challenging.
>
> So I'd again prefer not adding ifdef.
>
> [...]
>
> To summarize again, how about fixing the document but keeping the code as is?
If the expected behaviour is to silently fail, I agree, documenting this
should be the best option. I will submit a new patch with the documentation
update.
>
> [1] https://sashiko.dev/#/patchset/20260314093813.1359737-1-gutierrez.asier%40huawei-partners.com
>
>
> Thanks,
> SJ
>
--
Asier Gutierrez
Huawei
prev parent reply other threads:[~2026-03-16 7:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-14 9:38 gutierrez.asier
2026-03-14 16:51 ` SeongJae Park
2026-03-16 7:03 ` Gutierrez Asier [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=66131775-180b-4b9f-b7ce-61a3e077b6e6@huawei-partners.com \
--to=gutierrez.asier@huawei-partners.com \
--cc=akpm@linux-foundation.org \
--cc=artem.kuzin@huawei.com \
--cc=damon@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=sj@kernel.org \
--cc=stepanov.anatoly@huawei.com \
--cc=wangkefeng.wang@huawei.com \
--cc=yanquanmin1@huawei.com \
--cc=zuoze1@huawei.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