Skip to content

Commit 3b23a44

Browse files
nhatsmrtakpm00
authored andcommitted
mm/damon: implement a new DAMOS filter type for active pages
Patch series "mm/damon: introduce DAMOS filter type for active pages". The memory reclaim algorithm categorizes pages into active and inactive lists, separately for file and anon pages. The system's performance relies heavily on the (relative and absolute) accuracy of this categorization. This patch series add a new DAMOS filter for pages' activeness, giving us visibility into the access frequency of the pages on each list. This insight can help us diagnose issues with the active-inactive balancing dynamics, and make decisions to optimize reclaim efficiency and memory utilization. For instance, we might decide to enable DAMON_LRU_SORT, if we find that there are pages on the active list that are infrequently accessed, or less frequently accessed than pages on the inactive list. This patch (of 2): Implement a DAMOS filter type for active pages on DAMON kernel API, and add support of it from the physical address space DAMON operations set (paddr). Link: https://lkml.kernel.org/r/20250318183029.2062917-1-nphamcs@gmail.com Link: https://lkml.kernel.org/r/20250318183029.2062917-2-nphamcs@gmail.com Signed-off-by: Nhat Pham <nphamcs@gmail.com> Suggested-by: SeongJae Park <sj@kernel.org> Reviewed-by: SeongJae Park <sj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 98c183a commit 3b23a44

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

include/linux/damon.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ struct damos_stat {
334334
/**
335335
* enum damos_filter_type - Type of memory for &struct damos_filter
336336
* @DAMOS_FILTER_TYPE_ANON: Anonymous pages.
337+
* @DAMOS_FILTER_TYPE_ACTIVE: Active pages.
337338
* @DAMOS_FILTER_TYPE_MEMCG: Specific memcg's pages.
338339
* @DAMOS_FILTER_TYPE_YOUNG: Recently accessed pages.
339340
* @DAMOS_FILTER_TYPE_HUGEPAGE_SIZE: Page is part of a hugepage.
@@ -355,6 +356,7 @@ struct damos_stat {
355356
*/
356357
enum damos_filter_type {
357358
DAMOS_FILTER_TYPE_ANON,
359+
DAMOS_FILTER_TYPE_ACTIVE,
358360
DAMOS_FILTER_TYPE_MEMCG,
359361
DAMOS_FILTER_TYPE_YOUNG,
360362
DAMOS_FILTER_TYPE_HUGEPAGE_SIZE,

mm/damon/paddr.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ static bool damos_pa_filter_match(struct damos_filter *filter,
217217
case DAMOS_FILTER_TYPE_ANON:
218218
matched = folio_test_anon(folio);
219219
break;
220+
case DAMOS_FILTER_TYPE_ACTIVE:
221+
matched = folio_test_active(folio);
222+
break;
220223
case DAMOS_FILTER_TYPE_MEMCG:
221224
rcu_read_lock();
222225
memcg = folio_memcg_check(folio);

mm/damon/sysfs-schemes.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ static struct damon_sysfs_scheme_filter *damon_sysfs_scheme_filter_alloc(
344344
/* Should match with enum damos_filter_type */
345345
static const char * const damon_sysfs_scheme_filter_type_strs[] = {
346346
"anon",
347+
"active",
347348
"memcg",
348349
"young",
349350
"hugepage_size",

0 commit comments

Comments
 (0)