On Thu, 20 Feb 2025 11:35:07 -0800 SeongJae Park <sj@xxxxxxxxxx> wrote: > Decide whether to allow or reject by default on core and opertions layer > handled filters evaluation stages, based on the last-installed filter's > behavior. It is the opposite of the last installed filter's behavior. > If there is any operations layer handled filters, core layer handled > filters stage keeps allowing as the default behavior, since the last > filter of core layer handled filters in the case is not really the last > filter of the entire filtering stage. The last sentence describing behavior is not really implemented with this commit. See below. > > Signed-off-by: SeongJae Park <sj@xxxxxxxxxx> > --- > mm/damon/core.c | 31 +++++++++++++++++++++++++++++-- > 1 file changed, 29 insertions(+), 2 deletions(-) > > diff --git a/mm/damon/core.c b/mm/damon/core.c > index 78126a5145fd..9744ab9ca5c5 100644 > --- a/mm/damon/core.c > +++ b/mm/damon/core.c > @@ -864,6 +864,29 @@ static int damos_commit_ops_filters(struct damos *dst, struct damos *src) > return 0; > } > > +/** > + * damos_filters_default_reject() - decide whether to reject memory that didn't > + * match with any given filter. > + * @filters: Given DAMOS filters of a group. > + */ > +static bool damos_filters_default_reject(struct list_head *filters) > +{ > + struct damos_filter *last_filter; > + > + if (list_empty(filters)) > + return false; > + last_filter = list_last_entry(filters, struct damos_filter, list); > + return last_filter->allow; > +} > + > +static void damos_set_filters_default_reject(struct damos *s) > +{ > + s->core_filters_default_reject = > + damos_filters_default_reject(&s->filters); > + s->ops_filters_default_reject = > + damos_filters_default_reject(&s->ops_filters); > +} ->core_filters_default_reject should be 'false' if s->ops_filters is not empty, since the last one of ->ops_filters is not the real last filter. But this code is not handling the case. I will fix this in the next revision. Thanks, SJ [...]