All of lore.kernel.org
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: SeongJae Park <sj@kernel.org>,
	damon@lists.linux.dev, kernel-team@meta.com,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH 1/9] mm/damon/core: introduce damos->ops_filters
Date: Tue,  4 Mar 2025 13:19:05 -0800	[thread overview]
Message-ID: <20250304211913.53574-2-sj@kernel.org> (raw)
In-Reply-To: <20250304211913.53574-1-sj@kernel.org>

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

  reply	other threads:[~2025-03-04 21:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=20250304211913.53574-2-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=damon@lists.linux.dev \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.