@@ -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,
@@ -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;
}
@@ -345,6 +345,7 @@ static const char * const damon_sysfs_scheme_filter_type_strs[] = {
"anon",
"memcg",
"young",
+ "unmapped",
"addr",
"target",
};
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(+)