Skip to contentSkip to conversation

mm/damon: introduce pgidle_set probe filter type

PATCH Applied SJ Park 2 participants 11 messages Sep 10

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.

Changes from RFC v1.1
- RFC v1.1: https://lore.kernel.org/[email protected]
- Drop RFC tag.
Changes from RFC
- RFC: https://lore.kernel.org/[email protected]
- Rebase to latest mm-new.

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: db0399c7f55d733a66e5661c4300276629123b0b

Signature · 1 line
2.47.3
author maintainer
#1 lore raw

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 4a36f344bbc7c..abb529771091c 100644
@@ -782,11 +782,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
#2 lore raw

Re: [PATCH 1/5] mm/damon/api: introduce DAMON_FILTER_TYPE_PGIDLE_SET

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 7 lines

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.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
author maintainer
#3 lore raw

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 b8f4d28165dd7..5abfabaa339e0 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
#4 lore raw

Re: [PATCH 2/5] mm/damon/paddr: support DAMON_FILTER_TYPE_PGIDLE_SET

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 4 lines

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

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
author maintainer
#5 lore raw

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 4aecf34e39be2..d5dde97b3cd0d 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
#6 lore raw

Re: [PATCH 3/5] mm/damon/vaddr: support DAMON_FILTER_TYPE_PGIDLE_SET

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 4 lines

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

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
author maintainer
#7 lore raw

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
#8 lore raw

Re: [PATCH 4/5] mm/damon/sysfs: support DAMON_FILTER_TYPE_PGIDLE_SET

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 4 lines

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

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
author maintainer
#9 lore raw

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 8e980dde362de..cb116a82ff20b 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
#10 lore raw

Re: [PATCH 5/5] Docs/mm/damon/design: update for pgidle_set probe filter

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 4 lines

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

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5