This patch moves damon_pa_scheme_has_filter to ops-common. renaming
to damon_scheme_has_filter.
Doing so allows us to reuse its logic in the vaddr version
of DAMOS_STAT
Signed-off-by: Yueyang Pan <pyyjason@gmail.com>
---
mm/damon/ops-common.c | 9 +++++++++
mm/damon/ops-common.h | 2 ++
mm/damon/paddr.c | 11 +----------
3 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c
index 99321ff5cb92..3ebfa356ca46 100644
--- a/mm/damon/ops-common.c
+++ b/mm/damon/ops-common.c
@@ -412,3 +412,12 @@ unsigned long damon_migrate_pages(struct list_head *folio_list, int target_nid)
return nr_migrated;
}
+
+bool damon_scheme_has_filter(struct damos *s)
+{
+ struct damos_filter *f;
+
+ damos_for_each_ops_filter(f, s)
+ return true;
+ return false;
+}
diff --git a/mm/damon/ops-common.h b/mm/damon/ops-common.h
index 61ad54aaf256..8d5c5c7631ac 100644
--- a/mm/damon/ops-common.h
+++ b/mm/damon/ops-common.h
@@ -21,3 +21,5 @@ int damon_hot_score(struct damon_ctx *c, struct damon_region *r,
bool damos_folio_filter_match(struct damos_filter *filter, struct folio *folio);
unsigned long damon_migrate_pages(struct list_head *folio_list, int target_nid);
+
+bool damon_scheme_has_filter(struct damos *s);
diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c
index 53a55c5114fb..daeceed981a0 100644
--- a/mm/damon/paddr.c
+++ b/mm/damon/paddr.c
@@ -262,22 +262,13 @@ static unsigned long damon_pa_migrate(struct damon_region *r, struct damos *s,
return applied * PAGE_SIZE;
}
-static bool damon_pa_scheme_has_filter(struct damos *s)
-{
- struct damos_filter *f;
-
- damos_for_each_ops_filter(f, s)
- return true;
- return false;
-}
-
static unsigned long damon_pa_stat(struct damon_region *r, struct damos *s,
unsigned long *sz_filter_passed)
{
unsigned long addr;
struct folio *folio;
- if (!damon_pa_scheme_has_filter(s))
+ if (!damon_scheme_has_filter(s))
return 0;
addr = r->ar.start;
--
2.47.3
On Wed, 30 Jul 2025 10:19:55 -0700 Yueyang Pan <pyyjason@gmail.com> wrote: > This patch moves damon_pa_scheme_has_filter to ops-common. renaming > to damon_scheme_has_filter. > Doing so allows us to reuse its logic in the vaddr version > of DAMOS_STAT > > Signed-off-by: Yueyang Pan <pyyjason@gmail.com> > --- > mm/damon/ops-common.c | 9 +++++++++ > mm/damon/ops-common.h | 2 ++ > mm/damon/paddr.c | 11 +---------- > 3 files changed, 12 insertions(+), 10 deletions(-) > > diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c > index 99321ff5cb92..3ebfa356ca46 100644 > --- a/mm/damon/ops-common.c > +++ b/mm/damon/ops-common.c > @@ -412,3 +412,12 @@ unsigned long damon_migrate_pages(struct list_head *folio_list, int target_nid) > > return nr_migrated; > } > + > +bool damon_scheme_has_filter(struct damos *s) > +{ > + struct damos_filter *f; > + > + damos_for_each_ops_filter(f, s) > + return true; > + return false; > +} I should have tell this earlier, sorry. I now think it would be good to have ops-common.c own prefix, since this namee makes me expect the function is on DAMON core layer. Also, I use normal 'grep' and ctags at the best, and maybe I'm not the only one that that lazy at learning new tools. Following the weird and none-public naming convention we have on DAMON, damos_ops_ for DAMOS-related functions and damon_ops_ for monitoring-related functions would be the prefix for ops-common.c. So, what about renaming this to damos_ops_has_filter() if we have a chance to revision this once again? > diff --git a/mm/damon/ops-common.h b/mm/damon/ops-common.h > index 61ad54aaf256..8d5c5c7631ac 100644 > --- a/mm/damon/ops-common.h > +++ b/mm/damon/ops-common.h > @@ -21,3 +21,5 @@ int damon_hot_score(struct damon_ctx *c, struct damon_region *r, > > bool damos_folio_filter_match(struct damos_filter *filter, struct folio *folio); > unsigned long damon_migrate_pages(struct list_head *folio_list, int target_nid); > + > +bool damon_scheme_has_filter(struct damos *s); > diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c > index 53a55c5114fb..daeceed981a0 100644 > --- a/mm/damon/paddr.c > +++ b/mm/damon/paddr.c > @@ -262,22 +262,13 @@ static unsigned long damon_pa_migrate(struct damon_region *r, struct damos *s, > return applied * PAGE_SIZE; > } > > -static bool damon_pa_scheme_has_filter(struct damos *s) > -{ > - struct damos_filter *f; > - > - damos_for_each_ops_filter(f, s) > - return true; > - return false; > -} > - > static unsigned long damon_pa_stat(struct damon_region *r, struct damos *s, > unsigned long *sz_filter_passed) > { > unsigned long addr; > struct folio *folio; > > - if (!damon_pa_scheme_has_filter(s)) > + if (!damon_scheme_has_filter(s)) > return 0; > > addr = r->ar.start; > -- > 2.47.3 Otherwise, all looks good to me. Thanks, SJ
On Wed, Jul 30, 2025 at 10:45:06AM -0700, SeongJae Park wrote: > On Wed, 30 Jul 2025 10:19:55 -0700 Yueyang Pan <pyyjason@gmail.com> wrote: > > > This patch moves damon_pa_scheme_has_filter to ops-common. renaming > > to damon_scheme_has_filter. > > Doing so allows us to reuse its logic in the vaddr version > > of DAMOS_STAT > > > > Signed-off-by: Yueyang Pan <pyyjason@gmail.com> > > --- > > mm/damon/ops-common.c | 9 +++++++++ > > mm/damon/ops-common.h | 2 ++ > > mm/damon/paddr.c | 11 +---------- > > 3 files changed, 12 insertions(+), 10 deletions(-) > > > > diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c > > index 99321ff5cb92..3ebfa356ca46 100644 > > --- a/mm/damon/ops-common.c > > +++ b/mm/damon/ops-common.c > > @@ -412,3 +412,12 @@ unsigned long damon_migrate_pages(struct list_head *folio_list, int target_nid) > > > > return nr_migrated; > > } > > + > > +bool damon_scheme_has_filter(struct damos *s) > > +{ > > + struct damos_filter *f; > > + > > + damos_for_each_ops_filter(f, s) > > + return true; > > + return false; > > +} > > I should have tell this earlier, sorry. I now think it would be good to have > ops-common.c own prefix, since this namee makes me expect the function is on > DAMON core layer. Also, I use normal 'grep' and ctags at the best, and maybe > I'm not the only one that that lazy at learning new tools. > > Following the weird and none-public naming convention we have on DAMON, > damos_ops_ for DAMOS-related functions and damon_ops_ for monitoring-related > functions would be the prefix for ops-common.c. > > So, what about renaming this to damos_ops_has_filter() if we have a chance to > revision this once again? Thanks. I will fix it in the next version. > > > diff --git a/mm/damon/ops-common.h b/mm/damon/ops-common.h > > index 61ad54aaf256..8d5c5c7631ac 100644 > > --- a/mm/damon/ops-common.h > > +++ b/mm/damon/ops-common.h > > @@ -21,3 +21,5 @@ int damon_hot_score(struct damon_ctx *c, struct damon_region *r, > > > > bool damos_folio_filter_match(struct damos_filter *filter, struct folio *folio); > > unsigned long damon_migrate_pages(struct list_head *folio_list, int target_nid); > > + > > +bool damon_scheme_has_filter(struct damos *s); > > diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c > > index 53a55c5114fb..daeceed981a0 100644 > > --- a/mm/damon/paddr.c > > +++ b/mm/damon/paddr.c > > @@ -262,22 +262,13 @@ static unsigned long damon_pa_migrate(struct damon_region *r, struct damos *s, > > return applied * PAGE_SIZE; > > } > > > > -static bool damon_pa_scheme_has_filter(struct damos *s) > > -{ > > - struct damos_filter *f; > > - > > - damos_for_each_ops_filter(f, s) > > - return true; > > - return false; > > -} > > - > > static unsigned long damon_pa_stat(struct damon_region *r, struct damos *s, > > unsigned long *sz_filter_passed) > > { > > unsigned long addr; > > struct folio *folio; > > > > - if (!damon_pa_scheme_has_filter(s)) > > + if (!damon_scheme_has_filter(s)) > > return 0; > > > > addr = r->ar.start; > > -- > > 2.47.3 > > Otherwise, all looks good to me. > > > Thanks, > SJ Best Wishes Pan
© 2016 - 2025 Red Hat, Inc.