* [PATCH v2] mm/damon/core: document damos_commit_dests() failure semantics
@ 2026-03-20 14:36 SeongJae Park
0 siblings, 0 replies; only message in thread
From: SeongJae Park @ 2026-03-20 14:36 UTC (permalink / raw)
To: Andrew Morton; +Cc: Josh Law, SeongJae Park, damon, linux-kernel, linux-mm
From: Josh Law <objecting@objecting.org>
Add a kernel-doc-like comment to damos_commit_dests() documenting its
allocation failure contract: on -ENOMEM, the destination structure is
left in a partially torn-down state that is safe to deallocate via
damon_destroy_scheme(), but must not be reused for further commits.
This was unclear from the code alone and led to a separate patch [1]
attempting to reset nr_dests on failure. Make the intended usage
explicit so future readers do not repeat the confusion.
[1] https://lore.kernel.org/20260318214939.36100-1-objecting@objecting.org
Signed-off-by: Josh Law <objecting@objecting.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: SeongJae Park <sj@kernel.org>
Signed-off-by: SeongJae Park <sj@kernel.org>
---
Changes from v1
(https://lore.kernel.org/20260319071332.114595-1-objecting@objecting.org)
- Use kernel-doc like comment instead of kernel-doc for static function.
- Add a link to the previous discussion.
- Update description.
- Rebase to latest mm-new.
- Collect Reviewed-by: of SJ.
mm/damon/core.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 4dae03a37f9ac..df9f5e94e0ddd 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -1060,6 +1060,23 @@ static void damos_set_filters_default_reject(struct damos *s)
damos_filters_default_reject(&s->ops_filters);
}
+/*
+ * damos_commit_dests() - Copy migration destinations from @src to @dst.
+ * @dst: Destination structure to update.
+ * @src: Source structure to copy from.
+ *
+ * If the number of destinations has changed, the old arrays in @dst are freed
+ * and new ones are allocated. On success, @dst contains a full copy of
+ * @src's arrays and count.
+ *
+ * On allocation failure, @dst is left in a partially torn-down state: its
+ * arrays may be NULL and @nr_dests may not reflect the actual allocation
+ * sizes. The structure remains safe to deallocate via damon_destroy_scheme(),
+ * but callers must not reuse @dst for further commits — it should be
+ * discarded.
+ *
+ * Return: 0 on success, -ENOMEM on allocation failure.
+ */
static int damos_commit_dests(struct damos_migrate_dests *dst,
struct damos_migrate_dests *src)
{
base-commit: 4fbbbf18fd43c2d7b692749b7c853157f901b709
--
2.47.3
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-03-20 14:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-20 14:36 [PATCH v2] mm/damon/core: document damos_commit_dests() failure semantics SeongJae Park
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox