linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/9] mm/damon: make allow filters after reject filters useful and intuitive
@ 2025-03-04 21:19 SeongJae Park
  2025-03-04 21:19 ` [PATCH 1/9] mm/damon/core: introduce damos->ops_filters SeongJae Park
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: SeongJae Park @ 2025-03-04 21:19 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SeongJae Park, Jonathan Corbet, damon, kernel-team, linux-doc,
	linux-kernel, linux-mm

DAMOS filters do allow or reject elements of memory for given DAMOS
scheme only if those match the filter criterias.  For elements that
don't match any DAMOS filter, 'allowing' is the default behavior.  This
makes allow-filters that don't have any reject-filter after them
meaningless sources of overhead.  The decision was made to keep the
behavior consistent with that before the introduction of allow-filters.
This, however, makes usage of DAMOS filters confusing and inefficient.
It is more intuitive and still consistent behavior to reject by default
unless there is no filter at all or the last filter is a reject filter.
Update the filtering logic in the way and update documents to clarify
the behavior.

Note that this is changing the old behavior.  But the old behavior for
the problematic filter combination was definitely confusing, inefficient
and anyway useless.  Also, the behavior has relatively recently
introduced.  It is difficult to anticipate any user that depends on the
behavior.  Hence this is not a user-breaking behavior change but an
obvious improvement.

Changes from RFC v2
(https://lore.kernel.org/20250227015754.38789-1-sj@kernel.org)
- Wordsmith commit messages
- Rebase on latest mm-unstable

Changes from RFC v1
(https://lore.kernel.org/20250220193509.36379-1-sj@kernel.org)
- Set default behavior on core layer filtering stage as allow if any ops
  layer filter exists.
- Wordsmith commit messages
- Rebase on latest mm-unstable

SeongJae Park (9):
  mm/damon/core: introduce damos->ops_filters
  mm/damon/paddr: support ops_filters
  mm/damon/core: support committing ops_filters
  mm/damon/core: put ops-handled filters to damos->ops_filters
  mm/damon/paddr: support only damos->ops_filters
  mm/damon: add default allow/reject behavior fields to struct damos
  mm/damon/core: set damos_filter default allowance behavior based on
    installed filters
  mm/damon/paddr: respect ops_filters_default_reject
  Docs/mm/damon/design: update for changed filter-default behavior

 Documentation/mm/damon/design.rst | 10 ++--
 include/linux/damon.h             | 11 ++++
 mm/damon/core.c                   | 90 +++++++++++++++++++++++++++++--
 mm/damon/paddr.c                  |  8 +--
 4 files changed, 105 insertions(+), 14 deletions(-)


base-commit: 2f0a33016d6d4f184f2d3341af17a360b83e2ee2
-- 
2.39.5


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/9] mm/damon/core: introduce damos->ops_filters
  2025-03-04 21:19 [PATCH 0/9] mm/damon: make allow filters after reject filters useful and intuitive SeongJae Park
@ 2025-03-04 21:19 ` SeongJae Park
  2025-03-04 21:19 ` [PATCH 2/9] mm/damon/paddr: support ops_filters SeongJae Park
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: SeongJae Park @ 2025-03-04 21:19 UTC (permalink / raw)
  To: Andrew Morton; +Cc: SeongJae Park, damon, kernel-team, linux-kernel, linux-mm

DAMOS filters can be categorized into two groups depending on which
layer they are handled, namely core layer and ops layer.  The groups are
important because the filtering behavior depends on evaluation sequence
of filters, and core layer-handled filters are evaluated before
operations layer-handled ones.

The behavior is clearly documented, but the implementation is bit
inefficient and complicated.  All filters are maintained in a single
list (damos->filters) in mix.  Filters evaluation logics in core layer
and operations layer iterates all the filters on the list, while
skipping filters that should be not handled by the layer of the logic.
It is inefficient.  Making future extensions having differentiations for
filters of different handling layers will also be complicated.

Add a new list that will be used for having all operations layer-handled
DAMOS filters to DAMOS scheme data structure.  Also add the support of
its initialization and basic traversal functions.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 include/linux/damon.h | 8 ++++++++
 mm/damon/core.c       | 1 +
 2 files changed, 9 insertions(+)

diff --git a/include/linux/damon.h b/include/linux/damon.h
index b3e2c793c1f4..7f76e2e99f37 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -448,6 +448,7 @@ struct damos_access_pattern {
  * @wmarks:		Watermarks for automated (in)activation of this scheme.
  * @target_nid:		Destination node if @action is "migrate_{hot,cold}".
  * @filters:		Additional set of &struct damos_filter for &action.
+ * @ops_filters:	ops layer handling &struct damos_filter objects list.
  * @last_applied:	Last @action applied ops-managing entity.
  * @stat:		Statistics of this scheme.
  * @list:		List head for siblings.
@@ -508,6 +509,7 @@ struct damos {
 		int target_nid;
 	};
 	struct list_head filters;
+	struct list_head ops_filters;
 	void *last_applied;
 	struct damos_stat stat;
 	struct list_head list;
@@ -858,6 +860,12 @@ static inline unsigned long damon_sz_region(struct damon_region *r)
 #define damos_for_each_filter_safe(f, next, scheme) \
 	list_for_each_entry_safe(f, next, &(scheme)->filters, list)
 
+#define damos_for_each_ops_filter(f, scheme) \
+	list_for_each_entry(f, &(scheme)->ops_filters, list)
+
+#define damos_for_each_ops_filter_safe(f, next, scheme) \
+	list_for_each_entry_safe(f, next, &(scheme)->ops_filters, list)
+
 #ifdef CONFIG_DAMON
 
 struct damon_region *damon_new_region(unsigned long start, unsigned long end);
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 9d37d3664030..5415b7603d01 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -375,6 +375,7 @@ struct damos *damon_new_scheme(struct damos_access_pattern *pattern,
 	scheme->next_apply_sis = 0;
 	scheme->walk_completed = false;
 	INIT_LIST_HEAD(&scheme->filters);
+	INIT_LIST_HEAD(&scheme->ops_filters);
 	scheme->stat = (struct damos_stat){};
 	INIT_LIST_HEAD(&scheme->list);
 
-- 
2.39.5


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 2/9] mm/damon/paddr: support ops_filters
  2025-03-04 21:19 [PATCH 0/9] mm/damon: make allow filters after reject filters useful and intuitive SeongJae Park
  2025-03-04 21:19 ` [PATCH 1/9] mm/damon/core: introduce damos->ops_filters SeongJae Park
@ 2025-03-04 21:19 ` SeongJae Park
  2025-03-04 21:19 ` [PATCH 3/9] mm/damon/core: support committing ops_filters SeongJae Park
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: SeongJae Park @ 2025-03-04 21:19 UTC (permalink / raw)
  To: Andrew Morton; +Cc: SeongJae Park, damon, kernel-team, linux-kernel, linux-mm

DAMON keeps all DAMOS filters in damos->filters.  Upcoming changes will
make it to use damos->ops_filters for all operations layer handled DAMOS
filters, though.  DAMON physical address space operations set
implementation (paddr) is not ready for the changes, since it handles
only damos->filters.  To avoid any breakage during the upcoming changes,
make paddr to handle both lists.  After the change is made, ->filters
support on paddr can be safely removed.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 mm/damon/paddr.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c
index d5db313ca717..2b1ea568a431 100644
--- a/mm/damon/paddr.c
+++ b/mm/damon/paddr.c
@@ -260,6 +260,10 @@ static bool damos_pa_filter_out(struct damos *scheme, struct folio *folio)
 		if (damos_pa_filter_match(filter, folio))
 			return !filter->allow;
 	}
+	damos_for_each_ops_filter(filter, scheme) {
+		if (damos_pa_filter_match(filter, folio))
+			return !filter->allow;
+	}
 	return false;
 }
 
@@ -290,6 +294,12 @@ static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s,
 			break;
 		}
 	}
+	damos_for_each_ops_filter(filter, s) {
+		if (filter->type == DAMOS_FILTER_TYPE_YOUNG) {
+			install_young_filter = false;
+			break;
+		}
+	}
 	if (install_young_filter) {
 		filter = damos_new_filter(
 				DAMOS_FILTER_TYPE_YOUNG, true, false);
@@ -538,6 +548,8 @@ static bool damon_pa_scheme_has_filter(struct damos *s)
 
 	damos_for_each_filter(f, s)
 		return true;
+	damos_for_each_ops_filter(f, s)
+		return true;
 	return false;
 }
 
-- 
2.39.5


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 3/9] mm/damon/core: support committing ops_filters
  2025-03-04 21:19 [PATCH 0/9] mm/damon: make allow filters after reject filters useful and intuitive SeongJae Park
  2025-03-04 21:19 ` [PATCH 1/9] mm/damon/core: introduce damos->ops_filters SeongJae Park
  2025-03-04 21:19 ` [PATCH 2/9] mm/damon/paddr: support ops_filters SeongJae Park
@ 2025-03-04 21:19 ` SeongJae Park
  2025-03-04 21:19 ` [PATCH 4/9] mm/damon/core: put ops-handled filters to damos->ops_filters SeongJae Park
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: SeongJae Park @ 2025-03-04 21:19 UTC (permalink / raw)
  To: Andrew Morton; +Cc: SeongJae Park, damon, kernel-team, linux-kernel, linux-mm

DAMON kernel API callers should use damon_commit_ctx() to install DAMON
parameters including DAMOS filters.  But damos_commit_ops_filters(),
which is called by damon_commit_ctx() for filters installing, is not
handling damos->ops_filters.  Hence, no DAMON kernel API caller can use
damos->ops_filters.  Do the committing of the ops_filters to make it
usable.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 mm/damon/core.c | 40 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index 5415b7603d01..1daccccb5d67 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -820,7 +820,7 @@ static void damos_commit_filter(
 	damos_commit_filter_arg(dst, src);
 }
 
-static int damos_commit_filters(struct damos *dst, struct damos *src)
+static int damos_commit_core_filters(struct damos *dst, struct damos *src)
 {
 	struct damos_filter *dst_filter, *next, *src_filter, *new_filter;
 	int i = 0, j = 0;
@@ -848,6 +848,44 @@ static int damos_commit_filters(struct damos *dst, struct damos *src)
 	return 0;
 }
 
+static int damos_commit_ops_filters(struct damos *dst, struct damos *src)
+{
+	struct damos_filter *dst_filter, *next, *src_filter, *new_filter;
+	int i = 0, j = 0;
+
+	damos_for_each_ops_filter_safe(dst_filter, next, dst) {
+		src_filter = damos_nth_filter(i++, src);
+		if (src_filter)
+			damos_commit_filter(dst_filter, src_filter);
+		else
+			damos_destroy_filter(dst_filter);
+	}
+
+	damos_for_each_ops_filter_safe(src_filter, next, src) {
+		if (j++ < i)
+			continue;
+
+		new_filter = damos_new_filter(
+				src_filter->type, src_filter->matching,
+				src_filter->allow);
+		if (!new_filter)
+			return -ENOMEM;
+		damos_commit_filter_arg(new_filter, src_filter);
+		damos_add_filter(dst, new_filter);
+	}
+	return 0;
+}
+
+static int damos_commit_filters(struct damos *dst, struct damos *src)
+{
+	int err;
+
+	err = damos_commit_core_filters(dst, src);
+	if (err)
+		return err;
+	return damos_commit_ops_filters(dst, src);
+}
+
 static struct damos *damon_nth_scheme(int n, struct damon_ctx *ctx)
 {
 	struct damos *s;
-- 
2.39.5


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 4/9] mm/damon/core: put ops-handled filters to damos->ops_filters
  2025-03-04 21:19 [PATCH 0/9] mm/damon: make allow filters after reject filters useful and intuitive SeongJae Park
                   ` (2 preceding siblings ...)
  2025-03-04 21:19 ` [PATCH 3/9] mm/damon/core: support committing ops_filters SeongJae Park
@ 2025-03-04 21:19 ` SeongJae Park
  2025-03-04 21:19 ` [PATCH 5/9] mm/damon/paddr: support only damos->ops_filters SeongJae Park
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: SeongJae Park @ 2025-03-04 21:19 UTC (permalink / raw)
  To: Andrew Morton; +Cc: SeongJae Park, damon, kernel-team, linux-kernel, linux-mm

damos->ops_filters has introduced to be used for all operations layer
handled filters.  But DAMON kernel API callers can put any type of DAMOS
filters to any of damos->filters and damos->ops_filters.  DAMON
user-space ABI users have no way to use ->ops_filters at all.  Update
damos_add_filter(), which should be used by API callers to install DAMOS
filters, to add filters to ->filters and ->ops_filters depending on
their handling layer.  The change forces both API callers and ABI users
to use proper lists since ABI users use the API internally.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 mm/damon/core.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index 1daccccb5d67..3fbc31d17239 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -281,9 +281,24 @@ struct damos_filter *damos_new_filter(enum damos_filter_type type,
 	return filter;
 }
 
+static bool damos_filter_for_ops(enum damos_filter_type type)
+{
+	switch (type) {
+	case DAMOS_FILTER_TYPE_ADDR:
+	case DAMOS_FILTER_TYPE_TARGET:
+		return false;
+	default:
+		break;
+	}
+	return true;
+}
+
 void damos_add_filter(struct damos *s, struct damos_filter *f)
 {
-	list_add_tail(&f->list, &s->filters);
+	if (damos_filter_for_ops(f->type))
+		list_add_tail(&f->list, &s->ops_filters);
+	else
+		list_add_tail(&f->list, &s->filters);
 }
 
 static void damos_del_filter(struct damos_filter *f)
-- 
2.39.5


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 5/9] mm/damon/paddr: support only damos->ops_filters
  2025-03-04 21:19 [PATCH 0/9] mm/damon: make allow filters after reject filters useful and intuitive SeongJae Park
                   ` (3 preceding siblings ...)
  2025-03-04 21:19 ` [PATCH 4/9] mm/damon/core: put ops-handled filters to damos->ops_filters SeongJae Park
@ 2025-03-04 21:19 ` SeongJae Park
  2025-03-04 21:19 ` [PATCH 6/9] mm/damon: add default allow/reject behavior fields to struct damos SeongJae Park
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: SeongJae Park @ 2025-03-04 21:19 UTC (permalink / raw)
  To: Andrew Morton; +Cc: SeongJae Park, damon, kernel-team, linux-kernel, linux-mm

DAMON physical address space operation set implementation (paddr)
started handling both damos->filters and damos->ops_filters to avoid
breakage during the change for the ->ops_filters setup.  Now the change
is done, so paddr's support of ->filters is only a waste that can safely
be dropped.  Remove it.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 mm/damon/paddr.c | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c
index 2b1ea568a431..dded659bb110 100644
--- a/mm/damon/paddr.c
+++ b/mm/damon/paddr.c
@@ -256,10 +256,6 @@ static bool damos_pa_filter_out(struct damos *scheme, struct folio *folio)
 	if (scheme->core_filters_allowed)
 		return false;
 
-	damos_for_each_filter(filter, scheme) {
-		if (damos_pa_filter_match(filter, folio))
-			return !filter->allow;
-	}
 	damos_for_each_ops_filter(filter, scheme) {
 		if (damos_pa_filter_match(filter, folio))
 			return !filter->allow;
@@ -288,12 +284,6 @@ static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s,
 	struct folio *folio;
 
 	/* check access in page level again by default */
-	damos_for_each_filter(filter, s) {
-		if (filter->type == DAMOS_FILTER_TYPE_YOUNG) {
-			install_young_filter = false;
-			break;
-		}
-	}
 	damos_for_each_ops_filter(filter, s) {
 		if (filter->type == DAMOS_FILTER_TYPE_YOUNG) {
 			install_young_filter = false;
@@ -546,8 +536,6 @@ static bool damon_pa_scheme_has_filter(struct damos *s)
 {
 	struct damos_filter *f;
 
-	damos_for_each_filter(f, s)
-		return true;
 	damos_for_each_ops_filter(f, s)
 		return true;
 	return false;
-- 
2.39.5


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 6/9] mm/damon: add default allow/reject behavior fields to struct damos
  2025-03-04 21:19 [PATCH 0/9] mm/damon: make allow filters after reject filters useful and intuitive SeongJae Park
                   ` (4 preceding siblings ...)
  2025-03-04 21:19 ` [PATCH 5/9] mm/damon/paddr: support only damos->ops_filters SeongJae Park
@ 2025-03-04 21:19 ` SeongJae Park
  2025-03-04 21:19 ` [PATCH 7/9] mm/damon/core: set damos_filter default allowance behavior based on installed filters SeongJae Park
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: SeongJae Park @ 2025-03-04 21:19 UTC (permalink / raw)
  To: Andrew Morton; +Cc: SeongJae Park, damon, kernel-team, linux-kernel, linux-mm

Current default allow/reject behavior of filters handling stage has made
before introduction of the allow behavior.  For allow-filters usage, it
is confusing and inefficient.

It is more intuitive to decide the default filtering stage allow/reject
behavior as opposite to the last filter's behavior.  The decision should
be made separately for core and operations layers' filtering stages,
since last core layer-handled filter is not really a last filter if
there are operations layer handling filters.

Keeping separate decisions for the two categories can make the logic
simpler.  Add fields for storing the two decisions.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 include/linux/damon.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/damon.h b/include/linux/damon.h
index 7f76e2e99f37..52559475dbe7 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -502,6 +502,9 @@ struct damos {
 	 * layer-handled filters.  If true, operations layer allows it, too.
 	 */
 	bool core_filters_allowed;
+	/* whether to reject core/ops filters umatched regions */
+	bool core_filters_default_reject;
+	bool ops_filters_default_reject;
 /* public: */
 	struct damos_quota quota;
 	struct damos_watermarks wmarks;
-- 
2.39.5


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 7/9] mm/damon/core: set damos_filter default allowance behavior based on installed filters
  2025-03-04 21:19 [PATCH 0/9] mm/damon: make allow filters after reject filters useful and intuitive SeongJae Park
                   ` (5 preceding siblings ...)
  2025-03-04 21:19 ` [PATCH 6/9] mm/damon: add default allow/reject behavior fields to struct damos SeongJae Park
@ 2025-03-04 21:19 ` SeongJae Park
  2025-03-04 21:19 ` [PATCH 8/9] mm/damon/paddr: respect ops_filters_default_reject SeongJae Park
  2025-03-04 21:19 ` [PATCH 9/9] Docs/mm/damon/design: update for changed filter-default behavior SeongJae Park
  8 siblings, 0 replies; 10+ messages in thread
From: SeongJae Park @ 2025-03-04 21:19 UTC (permalink / raw)
  To: Andrew Morton; +Cc: SeongJae Park, damon, kernel-team, linux-kernel, linux-mm

Decide whether to allow or reject by default on core and opertions layer
handled filters evaluation stages.  It is decided as the opposite of the
last installed filter's behavior.  If there is no filter at all, allow
by default.  If there is any operations layer handled filters, core
layer's filtering stage sets allowing as the default behavior regardless
of the last filter of core layer-handling ones, since the last filter of
core layer handled filters in the case is not really the last filter of
the entire filtering stage.

Also, make the core layer's DAMOS filters handling stage uses the newly
set behavior field.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 mm/damon/core.c | 34 ++++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index 3fbc31d17239..194550e033b1 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -891,6 +891,32 @@ 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)
+{
+	if (!list_empty(&s->ops_filters))
+		s->core_filters_default_reject = false;
+	else
+		s->core_filters_default_reject =
+			damos_filters_default_reject(&s->filters);
+	s->ops_filters_default_reject =
+		damos_filters_default_reject(&s->ops_filters);
+}
+
 static int damos_commit_filters(struct damos *dst, struct damos *src)
 {
 	int err;
@@ -898,7 +924,11 @@ static int damos_commit_filters(struct damos *dst, struct damos *src)
 	err = damos_commit_core_filters(dst, src);
 	if (err)
 		return err;
-	return damos_commit_ops_filters(dst, src);
+	err = damos_commit_ops_filters(dst, src);
+	if (err)
+		return err;
+	damos_set_filters_default_reject(dst);
+	return 0;
 }
 
 static struct damos *damon_nth_scheme(int n, struct damon_ctx *ctx)
@@ -1580,7 +1610,7 @@ static bool damos_filter_out(struct damon_ctx *ctx, struct damon_target *t,
 			return !filter->allow;
 		}
 	}
-	return false;
+	return s->core_filters_default_reject;
 }
 
 /*
-- 
2.39.5


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 8/9] mm/damon/paddr: respect ops_filters_default_reject
  2025-03-04 21:19 [PATCH 0/9] mm/damon: make allow filters after reject filters useful and intuitive SeongJae Park
                   ` (6 preceding siblings ...)
  2025-03-04 21:19 ` [PATCH 7/9] mm/damon/core: set damos_filter default allowance behavior based on installed filters SeongJae Park
@ 2025-03-04 21:19 ` SeongJae Park
  2025-03-04 21:19 ` [PATCH 9/9] Docs/mm/damon/design: update for changed filter-default behavior SeongJae Park
  8 siblings, 0 replies; 10+ messages in thread
From: SeongJae Park @ 2025-03-04 21:19 UTC (permalink / raw)
  To: Andrew Morton; +Cc: SeongJae Park, damon, kernel-team, linux-kernel, linux-mm

Use damos->ops_filters_default_reject, which is set based on the
installed filters' behaviors, from physical address space DAMON
operations set.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 mm/damon/paddr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c
index dded659bb110..fba8b3c8ba30 100644
--- a/mm/damon/paddr.c
+++ b/mm/damon/paddr.c
@@ -260,7 +260,7 @@ static bool damos_pa_filter_out(struct damos *scheme, struct folio *folio)
 		if (damos_pa_filter_match(filter, folio))
 			return !filter->allow;
 	}
-	return false;
+	return scheme->ops_filters_default_reject;
 }
 
 static bool damon_pa_invalid_damos_folio(struct folio *folio, struct damos *s)
-- 
2.39.5


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 9/9] Docs/mm/damon/design: update for changed filter-default behavior
  2025-03-04 21:19 [PATCH 0/9] mm/damon: make allow filters after reject filters useful and intuitive SeongJae Park
                   ` (7 preceding siblings ...)
  2025-03-04 21:19 ` [PATCH 8/9] mm/damon/paddr: respect ops_filters_default_reject SeongJae Park
@ 2025-03-04 21:19 ` SeongJae Park
  8 siblings, 0 replies; 10+ messages in thread
From: SeongJae Park @ 2025-03-04 21:19 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SeongJae Park, Jonathan Corbet, damon, kernel-team, linux-doc,
	linux-kernel, linux-mm

Update the design documentation for changed DAMOS filters default
allowance behaviors.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 Documentation/mm/damon/design.rst | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
index 26c9ab10daf7..0cf678d98b1b 100644
--- a/Documentation/mm/damon/design.rst
+++ b/Documentation/mm/damon/design.rst
@@ -631,9 +631,10 @@ When multiple filters are installed, the group of filters that handled by the
 core layer are evaluated first.  After that, the group of filters that handled
 by the operations layer are evaluated.  Filters in each of the groups are
 evaluated in the installed order.  If a part of memory is matched to one of the
-filter, next filters are ignored.  If the memory passes through the filters
+filter, next filters are ignored.  If the part passes through the filters
 evaluation stage because it is not matched to any of the filters, applying the
-scheme's action to it is allowed, same to the behavior when no filter exists.
+scheme's action to it depends on the last filter's allowance type.  If the last
+filter was for allowing, the part of memory will be rejected, and vice versa.
 
 For example, let's assume 1) a filter for allowing anonymous pages and 2)
 another filter for rejecting young pages are installed in the order.  If a page
@@ -645,11 +646,6 @@ second reject-filter blocks it.  If the page is neither anonymous nor young,
 the page will pass through the filters evaluation stage since there is no
 matching filter, and the action will be applied to the page.
 
-Note that the action can equally be applied to memory that either explicitly
-filter-allowed or filters evaluation stage passed.  It means that installing
-allow-filters at the end of the list makes no practical change but only
-filters-checking overhead.
-
 Below ``type`` of filters are currently supported.
 
 - Core layer handled
-- 
2.39.5


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-03-04 21:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-04 21:19 [PATCH 0/9] mm/damon: make allow filters after reject filters useful and intuitive SeongJae Park
2025-03-04 21:19 ` [PATCH 1/9] mm/damon/core: introduce damos->ops_filters SeongJae Park
2025-03-04 21:19 ` [PATCH 2/9] mm/damon/paddr: support ops_filters SeongJae Park
2025-03-04 21:19 ` [PATCH 3/9] mm/damon/core: support committing ops_filters SeongJae Park
2025-03-04 21:19 ` [PATCH 4/9] mm/damon/core: put ops-handled filters to damos->ops_filters SeongJae Park
2025-03-04 21:19 ` [PATCH 5/9] mm/damon/paddr: support only damos->ops_filters SeongJae Park
2025-03-04 21:19 ` [PATCH 6/9] mm/damon: add default allow/reject behavior fields to struct damos SeongJae Park
2025-03-04 21:19 ` [PATCH 7/9] mm/damon/core: set damos_filter default allowance behavior based on installed filters SeongJae Park
2025-03-04 21:19 ` [PATCH 8/9] mm/damon/paddr: respect ops_filters_default_reject SeongJae Park
2025-03-04 21:19 ` [PATCH 9/9] Docs/mm/damon/design: update for changed filter-default behavior SeongJae Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox