linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] mm/damon: introduce DAMOS filter type for active pages
@ 2025-03-18 18:30 Nhat Pham
  2025-03-18 18:30 ` [PATCH 1/2] mm/damon: implement a new " Nhat Pham
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Nhat Pham @ 2025-03-18 18:30 UTC (permalink / raw)
  To: akpm; +Cc: sj, corbet, linux-mm, kernel-team, linux-kernel, linux-doc, damon

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.

Nhat Pham (2):
  mm/damon: implement a new DAMOS filter type for active pages
  Docs/mm/damon/design: document active DAMOS filter type

 Documentation/mm/damon/design.rst | 2 ++
 include/linux/damon.h             | 2 ++
 mm/damon/paddr.c                  | 3 +++
 mm/damon/sysfs-schemes.c          | 1 +
 4 files changed, 8 insertions(+)


base-commit: 40caf747267c18b6206e26a37d6ea6b695236c11
-- 
2.47.1


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

* [PATCH 1/2] mm/damon: implement a new DAMOS filter type for active pages
  2025-03-18 18:30 [PATCH 0/2] mm/damon: introduce DAMOS filter type for active pages Nhat Pham
@ 2025-03-18 18:30 ` Nhat Pham
  2025-03-18 18:45   ` SeongJae Park
  2025-03-18 18:30 ` [PATCH 2/2] Docs/mm/damon/design: document active DAMOS filter type Nhat Pham
  2025-03-18 18:51 ` [PATCH 0/2] mm/damon: introduce DAMOS filter type for active pages SeongJae Park
  2 siblings, 1 reply; 6+ messages in thread
From: Nhat Pham @ 2025-03-18 18:30 UTC (permalink / raw)
  To: akpm; +Cc: sj, corbet, linux-mm, kernel-team, linux-kernel, linux-doc, damon

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).

Suggested-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Nhat Pham <nphamcs@gmail.com>
---
 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 3db4f77261f5..47e36e6ea203 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -334,6 +334,7 @@ struct damos_stat {
 /**
  * enum damos_filter_type - Type of memory for &struct damos_filter
  * @DAMOS_FILTER_TYPE_ANON:	Anonymous pages.
+ * @DAMOS_FILTER_TYPE_ACTIVE:	Active pages.
  * @DAMOS_FILTER_TYPE_MEMCG:	Specific memcg's pages.
  * @DAMOS_FILTER_TYPE_YOUNG:	Recently accessed pages.
  * @DAMOS_FILTER_TYPE_HUGEPAGE_SIZE:	Page is part of a hugepage.
@@ -355,6 +356,7 @@ struct damos_stat {
  */
 enum damos_filter_type {
 	DAMOS_FILTER_TYPE_ANON,
+	DAMOS_FILTER_TYPE_ACTIVE,
 	DAMOS_FILTER_TYPE_MEMCG,
 	DAMOS_FILTER_TYPE_YOUNG,
 	DAMOS_FILTER_TYPE_HUGEPAGE_SIZE,
diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c
index b08847ef9b81..1b70d3f36046 100644
--- a/mm/damon/paddr.c
+++ b/mm/damon/paddr.c
@@ -217,6 +217,9 @@ static bool damos_pa_filter_match(struct damos_filter *filter,
 	case DAMOS_FILTER_TYPE_ANON:
 		matched = folio_test_anon(folio);
 		break;
+	case DAMOS_FILTER_TYPE_ACTIVE:
+		matched = folio_test_active(folio);
+		break;
 	case DAMOS_FILTER_TYPE_MEMCG:
 		rcu_read_lock();
 		memcg = folio_memcg_check(folio);
diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index 5023f2b690d6..23b562df0839 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -344,6 +344,7 @@ static struct damon_sysfs_scheme_filter *damon_sysfs_scheme_filter_alloc(
 /* Should match with enum damos_filter_type */
 static const char * const damon_sysfs_scheme_filter_type_strs[] = {
 	"anon",
+	"active",
 	"memcg",
 	"young",
 	"hugepage_size",
-- 
2.47.1



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

* [PATCH 2/2] Docs/mm/damon/design: document active DAMOS filter type
  2025-03-18 18:30 [PATCH 0/2] mm/damon: introduce DAMOS filter type for active pages Nhat Pham
  2025-03-18 18:30 ` [PATCH 1/2] mm/damon: implement a new " Nhat Pham
@ 2025-03-18 18:30 ` Nhat Pham
  2025-03-18 18:46   ` SeongJae Park
  2025-03-18 18:51 ` [PATCH 0/2] mm/damon: introduce DAMOS filter type for active pages SeongJae Park
  2 siblings, 1 reply; 6+ messages in thread
From: Nhat Pham @ 2025-03-18 18:30 UTC (permalink / raw)
  To: akpm; +Cc: sj, corbet, linux-mm, kernel-team, linux-kernel, linux-doc, damon

Document availability and meaning of "active" DAMOS filter type on
design document.  Since introduction of the type requires no additional
user ABI, usage and ABI document need no update.

Suggested-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Nhat Pham <nphamcs@gmail.com>
---
 Documentation/mm/damon/design.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
index aae3a691ee69..f12d33749329 100644
--- a/Documentation/mm/damon/design.rst
+++ b/Documentation/mm/damon/design.rst
@@ -656,6 +656,8 @@ Below ``type`` of filters are currently supported.
 - Operations layer handled, supported by only ``paddr`` operations set.
     - anon
         - Applied to pages that containing data that not stored in files.
+    - active
+        - Applied to active pages.
     - memcg
         - Applied to pages that belonging to a given cgroup.
     - young
-- 
2.47.1



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

* Re: [PATCH 1/2] mm/damon: implement a new DAMOS filter type for active pages
  2025-03-18 18:30 ` [PATCH 1/2] mm/damon: implement a new " Nhat Pham
@ 2025-03-18 18:45   ` SeongJae Park
  0 siblings, 0 replies; 6+ messages in thread
From: SeongJae Park @ 2025-03-18 18:45 UTC (permalink / raw)
  To: Nhat Pham
  Cc: SeongJae Park, akpm, corbet, linux-mm, kernel-team, linux-kernel,
	linux-doc, damon

On Tue, 18 Mar 2025 11:30:28 -0700 Nhat Pham <nphamcs@gmail.com> wrote:

> 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).

Great, thank you for this patch!

> 
> Suggested-by: SeongJae Park <sj@kernel.org>
> Signed-off-by: Nhat Pham <nphamcs@gmail.com>

Reviewed-by: SeongJae Park <sj@kernel.org>


Thanks,
SJ

[...]


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

* Re: [PATCH 2/2] Docs/mm/damon/design: document active DAMOS filter type
  2025-03-18 18:30 ` [PATCH 2/2] Docs/mm/damon/design: document active DAMOS filter type Nhat Pham
@ 2025-03-18 18:46   ` SeongJae Park
  0 siblings, 0 replies; 6+ messages in thread
From: SeongJae Park @ 2025-03-18 18:46 UTC (permalink / raw)
  To: Nhat Pham
  Cc: SeongJae Park, akpm, corbet, linux-mm, kernel-team, linux-kernel,
	linux-doc, damon

On Tue, 18 Mar 2025 11:30:29 -0700 Nhat Pham <nphamcs@gmail.com> wrote:

> Document availability and meaning of "active" DAMOS filter type on
> design document.  Since introduction of the type requires no additional
> user ABI, usage and ABI document need no update.

Thank you for keeping the document updated for this nice new feature!

> 
> Suggested-by: SeongJae Park <sj@kernel.org>
> Signed-off-by: Nhat Pham <nphamcs@gmail.com>

Reviewed-by: SeongJae Park <sj@kernel.org>


Thanks,
SJ


> ---
>  Documentation/mm/damon/design.rst | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
> index aae3a691ee69..f12d33749329 100644
> --- a/Documentation/mm/damon/design.rst
> +++ b/Documentation/mm/damon/design.rst
> @@ -656,6 +656,8 @@ Below ``type`` of filters are currently supported.
>  - Operations layer handled, supported by only ``paddr`` operations set.
>      - anon
>          - Applied to pages that containing data that not stored in files.
> +    - active
> +        - Applied to active pages.
>      - memcg
>          - Applied to pages that belonging to a given cgroup.
>      - young
> -- 
> 2.47.1


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

* Re: [PATCH 0/2] mm/damon: introduce DAMOS filter type for active pages
  2025-03-18 18:30 [PATCH 0/2] mm/damon: introduce DAMOS filter type for active pages Nhat Pham
  2025-03-18 18:30 ` [PATCH 1/2] mm/damon: implement a new " Nhat Pham
  2025-03-18 18:30 ` [PATCH 2/2] Docs/mm/damon/design: document active DAMOS filter type Nhat Pham
@ 2025-03-18 18:51 ` SeongJae Park
  2 siblings, 0 replies; 6+ messages in thread
From: SeongJae Park @ 2025-03-18 18:51 UTC (permalink / raw)
  To: Nhat Pham
  Cc: SeongJae Park, akpm, corbet, linux-mm, kernel-team, linux-kernel,
	linux-doc, damon

Hi Nhat,

On Tue, 18 Mar 2025 11:30:27 -0700 Nhat Pham <nphamcs@gmail.com> wrote:

> 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.

I agree to all the points, and thank you very much for this great patch series.

For other readers' information, DAMOS filters are for visibility of not only
the human users, but also DAMOS itself.  This new filter type will also be very
useful at making DAMOS schemes that respects LRU information (e.g., reclaim
DAMON-found cold pages but only if it is on inactive LRU list).


Thanks,
SJ

[...]


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

end of thread, other threads:[~2025-03-18 18:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-18 18:30 [PATCH 0/2] mm/damon: introduce DAMOS filter type for active pages Nhat Pham
2025-03-18 18:30 ` [PATCH 1/2] mm/damon: implement a new " Nhat Pham
2025-03-18 18:45   ` SeongJae Park
2025-03-18 18:30 ` [PATCH 2/2] Docs/mm/damon/design: document active DAMOS filter type Nhat Pham
2025-03-18 18:46   ` SeongJae Park
2025-03-18 18:51 ` [PATCH 0/2] mm/damon: introduce DAMOS filter type for active pages SeongJae Park

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