From: SeongJae Park <sj@kernel.org>
To: gutierrez.asier@huawei-partners.com
Cc: SeongJae Park <sj@kernel.org>,
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: [RFC PATCH v2 1/4] mm/damon: Generic context creation for modules
Date: Tue, 10 Mar 2026 17:57:58 -0700 [thread overview]
Message-ID: <20260311005759.90440-1-sj@kernel.org> (raw)
In-Reply-To: <20260310162420.4180562-2-gutierrez.asier@huawei-partners.com>
On Tue, 10 Mar 2026 16:24:17 +0000 <gutierrez.asier@huawei-partners.com> wrote:
> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
>
> It is more elegant to have a generic version of new context creation
> which receives the mode as a parameter.
>
> Signed-off-by: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
> Co-developed-by: Anatoly Stepanov <stepanov.anatoly@huawei.com>
> ---
> mm/damon/lru_sort.c | 5 +++--
> mm/damon/modules-common.c | 6 +++---
> mm/damon/modules-common.h | 4 ++--
> mm/damon/reclaim.c | 5 +++--
> 4 files changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c
> index 7bc5c0b2aea3..143ee0b21da6 100644
> --- a/mm/damon/lru_sort.c
> +++ b/mm/damon/lru_sort.c
> @@ -287,7 +287,8 @@ static int damon_lru_sort_apply_parameters(void)
> unsigned int hot_thres, cold_thres;
> int err;
>
> - err = damon_modules_new_paddr_ctx_target(¶m_ctx, ¶m_target);
> + err = damon_modules_new_ctx_target(¶m_ctx, ¶m_target,
> + DAMON_OPS_PADDR);
I like the name of the function is becoming shorter. But I'm not happy with
the fact the resulting calling code becomes longer.
I understand you are doing this extension because you want a version of the
function for vaddr. What about introducing another dedicated function, say,
damon_modules_new_vaddr_ctx_target() ?
And you can avoid duplicates between damon_modules_new_{p,v}addr_ctx_target()
by implementing internal function, say, damon_modules_new_ctx_target() that
receives the damon_ops_id. And damon_modules_new_{P,v}addr_ctx_target() will
just wrappers of damon_modules_new_ctx_target().
> if (err)
> return err;
>
> @@ -479,7 +480,7 @@ static int __init damon_lru_sort_init(void)
> err = -ENOMEM;
> goto out;
> }
> - err = damon_modules_new_paddr_ctx_target(&ctx, &target);
> + err = damon_modules_new_ctx_target(&ctx, &target, DAMON_OPS_PADDR);
Ditto.
> if (err)
> goto out;
>
> diff --git a/mm/damon/modules-common.c b/mm/damon/modules-common.c
> index 86d58f8c4f63..ae50b2fa3a86 100644
> --- a/mm/damon/modules-common.c
> +++ b/mm/damon/modules-common.c
> @@ -14,8 +14,8 @@
> * @ctxp: Pointer to save the point to the newly created context
> * @targetp: Pointer to save the point to the newly created target
> */
> -int damon_modules_new_paddr_ctx_target(struct damon_ctx **ctxp,
> - struct damon_target **targetp)
> +int damon_modules_new_ctx_target(struct damon_ctx **ctxp,
> + struct damon_target **targetp, enum damon_ops_id mode)
Nit. I'd suggest 'ops_id' as the parameter name, instead of 'mode'.
> {
> struct damon_ctx *ctx;
> struct damon_target *target;
> @@ -24,7 +24,7 @@ int damon_modules_new_paddr_ctx_target(struct damon_ctx **ctxp,
> if (!ctx)
> return -ENOMEM;
>
> - if (damon_select_ops(ctx, DAMON_OPS_PADDR)) {
> + if (damon_select_ops(ctx, mode)) {
> damon_destroy_ctx(ctx);
> return -EINVAL;
> }
> diff --git a/mm/damon/modules-common.h b/mm/damon/modules-common.h
> index f103ad556368..379b49c6a617 100644
> --- a/mm/damon/modules-common.h
> +++ b/mm/damon/modules-common.h
> @@ -45,5 +45,5 @@
> module_param_named(nr_##qt_exceed_name, stat.qt_exceeds, ulong, \
> 0400);
>
> -int damon_modules_new_paddr_ctx_target(struct damon_ctx **ctxp,
> - struct damon_target **targetp);
> +int damon_modules_new_ctx_target(struct damon_ctx **ctxp,
> + struct damon_target **targetp, enum damon_ops_id mode);
> diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c
> index 43d76f5bed44..24786a58683a 100644
> --- a/mm/damon/reclaim.c
> +++ b/mm/damon/reclaim.c
> @@ -197,7 +197,8 @@ static int damon_reclaim_apply_parameters(void)
> struct damos_filter *filter;
> int err;
>
> - err = damon_modules_new_paddr_ctx_target(¶m_ctx, ¶m_target);
> + err = damon_modules_new_ctx_target(¶m_ctx, ¶m_target,
> + DAMON_OPS_PADDR);
> if (err)
> return err;
>
> @@ -381,7 +382,7 @@ static int __init damon_reclaim_init(void)
> err = -ENOMEM;
> goto out;
> }
> - err = damon_modules_new_paddr_ctx_target(&ctx, &target);
> + err = damon_modules_new_ctx_target(&ctx, &target, DAMON_OPS_PADDR);
> if (err)
> goto out;
>
> --
> 2.43.0
Thanks,
SJ
next prev parent reply other threads:[~2026-03-11 0:58 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 16:24 [RFC PATCH v2 0/4] mm/damon: Support hot application detections gutierrez.asier
2026-03-10 16:24 ` [RFC PATCH v2 1/4] mm/damon: Generic context creation for modules gutierrez.asier
2026-03-11 0:57 ` SeongJae Park [this message]
2026-03-11 13:10 ` Gutierrez Asier
2026-03-11 14:15 ` SeongJae Park
2026-03-10 16:24 ` [RFC PATCH v2 2/4] mm/damon: Support for synchrounous huge pages collapse gutierrez.asier
2026-03-11 1:02 ` SeongJae Park
2026-03-11 13:11 ` Gutierrez Asier
2026-03-11 14:17 ` SeongJae Park
2026-03-10 16:24 ` [RFC PATCH v2 3/4] mm/damon: New module with hot application detection gutierrez.asier
2026-03-11 4:11 ` SeongJae Park
2026-03-11 13:45 ` Gutierrez Asier
2026-03-11 14:32 ` SeongJae Park
2026-03-10 16:24 ` [RFC PATCH v2 4/4] DAMON_HOT_HUGEPAGE documentation gutierrez.asier
2026-03-11 5:07 ` [RFC PATCH v2 0/4] mm/damon: Support hot application detections SeongJae Park
2026-03-11 13:08 ` Gutierrez Asier
2026-03-11 14:39 ` SeongJae Park
2026-03-11 23:55 ` SeongJae Park
2026-03-12 14:42 ` Gutierrez Asier
2026-03-13 0:08 ` SeongJae Park
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=20260311005759.90440-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=artem.kuzin@huawei.com \
--cc=damon@lists.linux.dev \
--cc=gutierrez.asier@huawei-partners.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.