From: Bijan Tabatabai <bijan311@gmail.com>
To: damon@lists.linux.dev, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org
Cc: sj@kernel.org, Andrew Morton <akpm@linux-foundation.org>,
corbet@lwn.net, Bijan Tabatabai <bijantabatab@micron.com>
Subject: [PATCH 1/5] mm/damon/core: Add damos_destroy_dests()
Date: Tue, 5 Aug 2025 11:20:18 -0500 [thread overview]
Message-ID: <20250805162022.4920-2-bijan311@gmail.com> (raw)
In-Reply-To: <20250805162022.4920-1-bijan311@gmail.com>
From: Bijan Tabatabai <bijantabatab@micron.com>
This patch adds damos_destroy_dests(), which is used to free a struct
damos_migrate_dests. Currently, the contents of a struct
damos_migrate_dests in freed inline in damon_destroy_scheme(). Moving
the code to a separate function is useful for when damos_migrate_dest
structs need to also be freed elsewhere.
Signed-off-by: Bijan Tabatabai <bijantabatab@micron.com>
---
include/linux/damon.h | 2 ++
mm/damon/core.c | 9 +++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/include/linux/damon.h b/include/linux/damon.h
index 6b797120d2f2..a851c8bc2e52 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -914,6 +914,8 @@ struct damos_quota_goal *damos_new_quota_goal(
void damos_add_quota_goal(struct damos_quota *q, struct damos_quota_goal *g);
void damos_destroy_quota_goal(struct damos_quota_goal *goal);
+void damos_destroy_dests(struct damos_migrate_dests *dests);
+
struct damos *damon_new_scheme(struct damos_access_pattern *pattern,
enum damos_action action,
unsigned long apply_interval_us,
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 6a2fe1f2c952..07b4fc5a9790 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -359,6 +359,12 @@ void damos_destroy_quota_goal(struct damos_quota_goal *g)
damos_free_quota_goal(g);
}
+void damos_destroy_dests(struct damos_migrate_dests *dests)
+{
+ kfree(dests->node_id_arr);
+ kfree(dests->weight_arr);
+}
+
/* initialize fields of @quota that normally API users wouldn't set */
static struct damos_quota *damos_quota_init(struct damos_quota *quota)
{
@@ -451,8 +457,7 @@ void damon_destroy_scheme(struct damos *s)
damos_for_each_filter_safe(f, next, s)
damos_destroy_filter(f);
- kfree(s->migrate_dests.node_id_arr);
- kfree(s->migrate_dests.weight_arr);
+ damos_destroy_dests(&s->migrate_dests);
damon_del_scheme(s);
damon_free_scheme(s);
}
--
2.43.5
next prev parent reply other threads:[~2025-08-05 16:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-05 16:20 [PATCH 0/5] mm/damon/sysfs: Add commands useful for using migration dests Bijan Tabatabai
2025-08-05 16:20 ` Bijan Tabatabai [this message]
2025-08-05 16:20 ` [PATCH 2/5] mm/damon/sysfs: Implement a command to only commit scheme dests Bijan Tabatabai
2025-08-05 16:20 ` [PATCH 3/5] mm/damon/sysfs: Implement a command to wait until schemes are applied Bijan Tabatabai
2025-08-05 16:20 ` [PATCH 4/5] Docs/ABI/damon: Document new DAMON commands Bijan Tabatabai
2025-08-05 16:20 ` [PATCH 5/5] Docs/admin-guide/mm/damon/usage: " Bijan Tabatabai
2025-08-06 0:40 ` [PATCH 0/5] mm/damon/sysfs: Add commands useful for using migration dests SeongJae Park
2025-08-06 1:27 ` Bijan Tabatabai
2025-08-06 4:15 ` SeongJae Park
-- strict thread matches above, loose matches on Subject: below --
2025-08-10 5:55 [PATCH 2/5] mm/damon/sysfs: Implement a command to only commit scheme dests kernel test robot
2025-08-11 7:00 ` Dan Carpenter
2025-08-11 16:35 ` 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=20250805162022.4920-2-bijan311@gmail.com \
--to=bijan311@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=bijantabatab@micron.com \
--cc=corbet@lwn.net \
--cc=damon@lists.linux.dev \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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 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.