Skip to contentSkip to conversation

mm/damon: introduce pgidle_set probe filter type

RFC PATCH New SJ Park 1 participant 6 messages Sep 6

Subsystems (4)
lore
Share & tools
lore

SJ Park

author maintainer
#0 lore raw

cover mm/damon: introduce pgidle_set probe filter type

Users can do effective access monitoring with DAMON, using set_pgidle probe prep operation and pgidle_unset allowing probe filter. In the setup, high probe_hits means the region was accessed frequently. Zero probe_hits means the region was not accessed. The filter, however, matches only the memory that can show the idleness. Regions of zero probe_hits may contain memory that was just unable to show the idleness. On virtual address space based monitoring, for example, non-present pages are reported as cold. It is truly cold, but if the purpose is to make some operations like reclaiming or compressing the data, this is not really useful. Introduce a new probe filter type, pgidle_set, that confirms the page is marked as idle. Using it instead of pgidle_unset, users can find cold pages that can effectively be processed.

Patch 1 introduces the pgidle_set probe filter type to DAMON kernel API. Patches 2 and 3 add support for it on physical and virtual address space operation sets, respectively. Patch 4 adds support for it on the DAMON sysfs interface. Finally, patch 5 updates the documentation for the new filter type.

SJ Park (5):
mm/damon/api: introduce DAMON_FILTER_TYPE_PGIDLE_SET mm/damon/paddr: support DAMON_FILTER_TYPE_PGIDLE_SET mm/damon/vaddr: support DAMON_FILTER_TYPE_PGIDLE_SET mm/damon/sysfs: support DAMON_FILTER_TYPE_PGIDLE_SET Docs/mm/damon/design: update for pgidle_set probe filter

 Documentation/mm/damon/design.rst | 3 ++-
 include/linux/damon.h             | 2 ++
 mm/damon/paddr.c                  | 6 ++++++
 mm/damon/sysfs.c                  | 4 ++++
 mm/damon/vaddr.c                  | 7 +++++++
 5 files changed, 21 insertions(+), 1 deletion(-)

base-commit: 1c9ae14f592158ed68845f7552f582545cb95c9a

Signature · 1 line
2.47.3
author maintainer
#1 lore raw

RFC PATCH 1/5 mm/damon/api: introduce DAMON_FILTER_TYPE_PGIDLE_SET

DAMON_FILTER_TYPE_PGIDLE_UNSET matches only memory that was able to confirm if it is marked as idle. If the memory cannot be marked as idle, it simply doesn't match. Hence, finding memory that was marked as idle with only DAMON_FILTER_TYPE_PGIDLE_UNSET is impossible. Introduce a new filter for the purpose, DAMON_FILTER_TYPE_PGIDLE_SET.

---
 include/linux/damon.h | 2 ++
 1 file changed, 2 insertions(+)
include/linux/damon.h +2 -0
index 871d26adf6ae5..16800b3dc379b 100644
@@ -774,11 +774,13 @@ struct damon_prep {
  * @DAMON_FILTER_TYPE_ANON:		Anonymous pages.
  * @DAMON_FILTER_TYPE_MEMCG:		Specific memcg's pages.
  * @DAMON_FILTER_TYPE_PGIDLE_UNSET:	Pgidle is unset.
+ * @DAMON_FILTER_TYPE_PGIDLE_SET:	Pgidle is set.
  */
 enum damon_filter_type {
 	DAMON_FILTER_TYPE_ANON,
 	DAMON_FILTER_TYPE_MEMCG,
 	DAMON_FILTER_TYPE_PGIDLE_UNSET,
+	DAMON_FILTER_TYPE_PGIDLE_SET,
 };
 
 /**
Signature · 1 line
2.47.3
author maintainer
#2 lore raw

RFC PATCH 2/5 mm/damon/paddr: support DAMON_FILTER_TYPE_PGIDLE_SET

In reply to SJ Park

Implement DAMON_FILTER_TYPE_PGIDLE_SET support on the physical address space DAMON operation set (paddr).

---
 mm/damon/paddr.c | 6 ++++++
 1 file changed, 6 insertions(+)
mm/damon/paddr.c +6 -0
index d7c81829445ba..79195026b903a 100644
@@ -151,6 +151,12 @@ static bool damon_pa_filter_match(struct damon_filter *filter,
 		else
 			matched = damon_folio_young(folio);
 		break;
+	case DAMON_FILTER_TYPE_PGIDLE_SET:
+		if (!folio)
+			matched = false;
+		else
+			matched = damon_folio_young(folio) == false;
+		break;
 	default:
 		return damon_ops_filter_match(filter, folio);
 	}
Signature · 1 line
2.47.3
author maintainer
#3 lore raw

RFC PATCH 3/5 mm/damon/vaddr: support DAMON_FILTER_TYPE_PGIDLE_SET

In reply to SJ Park

Implement DAMON_FILTER_TYPE_PGIDLE_SET support on the virtual address space DAMON operation set (vaddr).

---
 mm/damon/vaddr.c | 7 +++++++
 1 file changed, 7 insertions(+)
mm/damon/vaddr.c +7 -0
index 9a38dc89a156e..7063356370c34 100644
@@ -550,6 +550,13 @@ static bool damon_va_filter_match(struct damon_filter *filter,
 			matched = damon_va_young_addr(folio, pte, pmd, mm,
 					addr);
 		break;
+	case DAMON_FILTER_TYPE_PGIDLE_SET:
+		if (!folio)
+			matched = false;
+		else
+			matched = !damon_va_young_addr(folio, pte, pmd, mm,
+					addr);
+		break;
 	default:
 		return damon_ops_filter_match(filter, folio);
 	}
Signature · 1 line
2.47.3
author maintainer
#4 lore raw

RFC PATCH 4/5 mm/damon/sysfs: support DAMON_FILTER_TYPE_PGIDLE_SET

In reply to SJ Park

Extend DAMON sysfs interface to let users setup
DAMON_FILTER_TYPE_PGIDLE_SET probe filter.

---
 mm/damon/sysfs.c | 4 ++++
 1 file changed, 4 insertions(+)
mm/damon/sysfs.c +4 -0
index b576e97cbfdb8..51fa506c879b0 100644
@@ -1001,6 +1001,10 @@ damon_sysfs_filter_type_names[] = {
 		.type = DAMON_FILTER_TYPE_PGIDLE_UNSET,
 		.name = "pgidle_unset",
 	},
+	{
+		.type = DAMON_FILTER_TYPE_PGIDLE_SET,
+		.name = "pgidle_set",
+	},
 };
 
 static ssize_t type_show(struct kobject *kobj,
Signature · 1 line
2.47.3
author maintainer
#5 lore raw

RFC PATCH 5/5 Docs/mm/damon/design: update for pgidle_set probe filter

In reply to SJ Park

Update DAMON design document for the newly added pgidle_set probe filter type.

---
 Documentation/mm/damon/design.rst | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/mm/damon/design.rst +2 -1
index aac84de261aa8..22b785cd11dfe 100644
@@ -299,6 +299,7 @@ filter types.  Currently below filter types are supported.
 - ``memcg``: Same to that for DAMOS filters.
 - ``pgidle_unset``: Matches if the page for the memory is marked as not
   access-idle.
+- ``pgidle_set``: Matches if the page for the memory is marked as access-idle.
 
 If such probes are registered, DAMON executes the probes for each region's
 sampling memory when it does the access :ref:`sampling
@@ -314,7 +315,7 @@ actions are registered, DAMON applies the actions to each region's sampling
 memory before starting the next sampling interval.  Currently only one action,
 ``set_pgidle`` is supported.  The action marks the page for the probing target
 memory as access-idle.  This can be useful to be used together with
-``pgidle_unset`` probe filter.
+``pgidle_unset`` or ``pgidle_set`` probe filter.
 
 This is a sampling based mechanism.  Hence, it is lightweight but the output
 may include some measurement errors.  The output should be used with good
Signature · 1 line
2.47.3