linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] mm/damon: introduce DAMOS filter type UNMAPPED
@ 2024-11-27 20:56 SeongJae Park
  0 siblings, 0 replies; only message in thread
From: SeongJae Park @ 2024-11-27 20:56 UTC (permalink / raw)
  Cc: SeongJae Park, Gregory Price, damon, linux-mm, linux-kernel

Some DAMOS actions may better to be applied to only mapped, or unmapped
pages.  For example, users might want to use NUMA hint fault based
CXL-memory promotion for mapped pages, and DAMOS-based promotion for
unmapped pages.  For another example, users might want to proactively
reclaim only unmapped page cache, since some people do mmap() for only
performance-important files, to reduce read()/write() system call
overheads.  To support such use cases, introduce a new DAMOS filter type
for unmapped pages.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
It is unclear if the example usages are realistic, and how much benefit
this idea will provide for the example usages.  This is for showing only
more specific shape of the idea, and hence RFC.  No test other than
build on my machine has run.

 include/linux/damon.h    | 2 ++
 mm/damon/paddr.c         | 3 +++
 mm/damon/sysfs-schemes.c | 1 +
 3 files changed, 6 insertions(+)

diff --git a/include/linux/damon.h b/include/linux/damon.h
index 9d8bb6116df4..10fc6df52111 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -315,6 +315,7 @@ struct damos_stat {
  * @DAMOS_FILTER_TYPE_ANON:	Anonymous pages.
  * @DAMOS_FILTER_TYPE_MEMCG:	Specific memcg's pages.
  * @DAMOS_FILTER_TYPE_YOUNG:	Recently accessed pages.
+ * @DAMOS_FILTER_TYPE_UNMAPPED:	Unmapped pages.
  * @DAMOS_FILTER_TYPE_ADDR:	Address range.
  * @DAMOS_FILTER_TYPE_TARGET:	Data Access Monitoring target.
  * @NR_DAMOS_FILTER_TYPES:	Number of filter types.
@@ -334,6 +335,7 @@ enum damos_filter_type {
 	DAMOS_FILTER_TYPE_ANON,
 	DAMOS_FILTER_TYPE_MEMCG,
 	DAMOS_FILTER_TYPE_YOUNG,
+	DAMOS_FILTER_TYPE_UNMAPPED,
 	DAMOS_FILTER_TYPE_ADDR,
 	DAMOS_FILTER_TYPE_TARGET,
 	NR_DAMOS_FILTER_TYPES,
diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c
index 4733aaddcae8..b3cb2578a201 100644
--- a/mm/damon/paddr.c
+++ b/mm/damon/paddr.c
@@ -222,6 +222,9 @@ static bool __damos_pa_filter_out(struct damos_filter *filter,
 		if (matched)
 			damon_folio_mkold(folio);
 		break;
+	case DAMOS_FILTER_TYPE_UNMAPPED:
+		matched = !folio_mapped(folio) || !folio_raw_mapping(folio);
+		break;
 	default:
 		break;
 	}
diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index 6cc976b8e363..25356fe99273 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -345,6 +345,7 @@ static const char * const damon_sysfs_scheme_filter_type_strs[] = {
 	"anon",
 	"memcg",
 	"young",
+	"unmapped",
 	"addr",
 	"target",
 };
-- 
2.39.5



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-11-27 20:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-27 20:56 [RFC PATCH] mm/damon: introduce DAMOS filter type UNMAPPED SeongJae Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).