From: SJ Park <sj@kernel.org>
Cc: SJ Park <sj@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
damon@lists.linux.dev, linux-mm@kvack.org
Subject: [RFC PATCH v3 2/7] mm/damon/vaddr: use damos->last_applied for migrate action
Date: Fri, 27 Nov 2026 14:27:13 -0800 [thread overview]
Message-ID: <20261127222719.105510-3-sj@kernel.org> (raw)
In-Reply-To: <20261127222719.105510-1-sj@kernel.org>
To avoid applying the same DAMOS action multiple times to folios that
are located across adjacent regions, damos->last_applied was introduced.
DAMOS_MIGRATE_{HOT,COLD} action support in vaddr is not utilizing it.
Use it to avoid unnecessarily applying the same action to the same folio
multiple times.
Signed-off-by: SJ Park <sj@kernel.org>
---
mm/damon/vaddr.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
index ca7ce9bd96e7..c8f93a19c840 100644
--- a/mm/damon/vaddr.c
+++ b/mm/damon/vaddr.c
@@ -837,6 +837,12 @@ static void damos_va_migrate_dests_add(struct folio *folio,
list_add(&folio->lru, &migration_lists[i]);
}
+static inline bool damos_va_invalid_folio(struct folio *folio,
+ struct damos *s)
+{
+ return !folio || folio == s->last_applied;
+}
+
static int damos_va_migrate_pmd_entry(pmd_t *pmd, unsigned long addr,
unsigned long next, struct mm_walk *walk)
{
@@ -856,8 +862,9 @@ static int damos_va_migrate_pmd_entry(pmd_t *pmd, unsigned long addr,
if (!pmd_present(pmde))
goto huge_out;
folio = vm_normal_folio_pmd(walk->vma, addr, pmde);
- if (!folio)
+ if (damos_va_invalid_folio(folio, s))
goto huge_out;
+ s->last_applied = folio;
if (damos_va_filter_out(s, folio, walk->vma, addr, NULL, pmd))
goto huge_out;
damos_va_migrate_dests_add(folio, walk->vma, addr, s,
@@ -881,10 +888,11 @@ static int damos_va_migrate_pmd_entry(pmd_t *pmd, unsigned long addr,
if (pte_none(ptent) || !pte_present(ptent))
continue;
folio = vm_normal_folio(walk->vma, addr, ptent);
- if (!folio)
- continue;
page_idx = folio_page_idx(folio, pte_page(ptent));
nr = folio_nr_pages(folio) - page_idx;
+ if (damos_va_invalid_folio(folio, s))
+ continue;
+ s->last_applied = folio;
if (damos_va_filter_out(s, folio, walk->vma, addr, pte, NULL))
continue;
damos_va_migrate_dests_add(folio, walk->vma, addr, s,
@@ -993,12 +1001,6 @@ struct damos_va_stat_private {
unsigned long *sz_filter_passed;
};
-static inline bool damos_va_invalid_folio(struct folio *folio,
- struct damos *s)
-{
- return !folio || folio == s->last_applied;
-}
-
static int damos_va_stat_pmd_entry(pmd_t *pmd, unsigned long addr,
unsigned long next, struct mm_walk *walk)
{
--
2.47.3
next prev parent reply other threads:[~2026-11-27 22:27 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 22:27 [RFC PATCH v3 0/7] mm/damon: various improvements/cleanups for code, tests and comments SJ Park
2026-11-27 22:27 ` [RFC PATCH v3 1/7] mm/damon/vaddr: advance migration attempt in folio level for filter out SJ Park
2026-11-27 22:27 ` SJ Park [this message]
2026-11-27 22:33 ` [RFC PATCH v3 2/7] mm/damon/vaddr: use damos->last_applied for migrate action sashiko-bot
2026-11-27 22:39 ` SJ Park
2026-11-27 22:27 ` [RFC PATCH v3 3/7] mm/damon/vaddr: implement sz_filter_passed for migrate_{hot,cold} action SJ Park
2026-11-27 22:35 ` sashiko-bot
2026-11-27 22:41 ` SJ Park
2026-11-27 22:27 ` [RFC PATCH v3 4/7] mm/damon/sysfs-schemes: drop redundant and racy zero target_value check SJ Park
2026-11-27 22:27 ` [RFC PATCH v3 5/7] selftests/damon/damos_apply_interval: remove unused variables SJ Park
2026-11-27 22:27 ` [RFC PATCH v3 6/7] selftests/damon: remove unused imports of sys and time modules SJ Park
2026-11-27 22:27 ` [RFC PATCH v3 7/7] mm/damon: update file intro comments to call DAMON just DAMON SJ Park
2026-11-27 22:35 ` [RFC PATCH v3 0/7] mm/damon: various improvements/cleanups for code, tests and comments sashiko-bot
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=20261127222719.105510-3-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=linux-mm@kvack.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox