mm-damon-core-do-non-safe-region-walk-on-kdamond_apply_schemes.patch removed from -mm tree
The quilt patch titled
Subject: mm/damon/core: do non-safe region walk on kdamond_apply_schemes()
has been removed from the -mm tree. Its filename was
mm-damon-core-do-non-safe-region-walk-on-kdamond_apply_schemes.patch
This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: SeongJae Park <[email protected]>
Subject: mm/damon/core: do non-safe region walk on kdamond_apply_schemes()
Date: Fri, 27 Feb 2026 09:06:21 -0800
kdamond_apply_schemes() is using damon_for_each_region_safe(), which is safe for deallocation of the region inside the loop. However, the loop internal logic does not deallocate regions. Hence it is only wasting the next pointer. Also, it causes a problem.
When an address filter is applied, and there is a region that intersects with the filter, the filter splits the region on the filter boundary. The intention is to let DAMOS apply action to only filtered-in address ranges. However, it is using damon_for_each_region_safe(), which sets the next region before the execution of the iteration. Hence, the region that split and now will be next to the previous region, is simply ignored. As a result, DAMOS applies the action to target regions bit slower than expected, when the address filter is used. Shouldn't be a big problem but definitely better to be fixed. damos_skip_charged_region() was working around the issue using a double pointer hack.
Use damon_for_each_region(), which is safe for this use case. And drop the work around in damos_skip_charged_region().
---
mm/damon/core.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
mm/damon/core.c renamed from mm/damon/core.c~mm-damon-core-do-non-safe-region-walk-on-kdamond_apply_schemes +11 -11
@@ -1717,17 +1717,18 @@ static bool damos_valid_target(struct da* This function checks if a given region should be skipped or not for the * reason. If only the starting part of the region has previously charged, * this function splits the region into two so that the second one covers the -* area that not charged in the previous charge widnow and saves the second -* region in *rp and returns false, so that the caller can apply DAMON action -* to the second one. +* area that not charged in the previous charge widnow, and return true. The +* caller can see the second one on the next iteration of the region walk. +* Note that this means the caller should use damon_for_each_region() instead +* of damon_for_each_region_safe(). If damon_for_each_region_safe() is used, +* the second region will just be ignored. * -* Return: true if the region should be entirely skipped, false otherwise. +* Return: true if the region should be skipped, false otherwise. */ static bool damos_skip_charged_region (struct damon_target *t, -struct damon_region **rp,struct damos *s, +struct damon_region *r,struct damos *s,unsigned long min_region_sz) { -struct damon_region *r = *rp;struct damos_quota *quota = &s->quota;unsigned long sz_to_skip;
@@ -1754,8 +1755,7 @@ static bool damos_skip_charged_region(st sz_to_skip = min_region_sz; }damon_split_region_at (t, r, sz_to_skip); - r =damon_next_region (r); - *rp = r; +return true; } quota->charge_target_from =NULL ; quota->charge_addr_from =0 ;
@@ -2014,7 +2014,7 @@ static void damon_do_apply_schemes(strucif (quota->esz && quota->charged_sz >= quota->esz)continue ; -if (damos_skip_charged_region (t, &r, s, c->min_region_sz)) +if (damos_skip_charged_region (t, r, s, c->min_region_sz))continue ; if (s->max_nr_snapshots &&
@@ -2357,7 +2357,7 @@ static void damos_trace_stat(struct damostatic void kdamond_apply_schemes (struct damon_ctx *c) {struct damon_target *t; -struct damon_region *r, *next_r; +struct damon_region *r;struct damos *s;unsigned long sample_interval = c->attrs.sample_interval ? c->attrs.sample_interval :1 ;
@@ -2383,7 +2383,7 @@ static void kdamond_apply_schemes(structif (c->ops.target_valid && c->ops.target_valid (t) == false)continue ; -damon_for_each_region_safe (r, next_r, t) +damon_for_each_region (r, t)damon_do_apply_schemes (c, t, r); }
_
Patches currently in -mm which might be from [email protected] are
mm-damon-add-config_damon_debug_sanity.patch mm-damon-core-add-damon_new_region-debug_sanity-check.patch mm-damon-core-add-damon_del_region-debug_sanity-check.patch mm-damon-core-add-damon_nr_regions-debug_sanity-check.patch mm-damon-core-add-damon_merge_two_regions-debug_sanity-check.patch mm-damon-core-add-damon_merge_regions_of-debug_sanity-check.patch mm-damon-core-add-damon_split_region_at-debug_sanity-check.patch mm-damon-core-add-damon_reset_aggregated-debug_sanity-check.patch mm-damon-tests-kunitconifg-enable-damon_debug_sanity.patch selftests-damon-config-enable-damon_debug_sanity.patch mm-damon-tests-core-kunit-add-a-test-for-damon_commit_ctx.patch docs-mm-damon-design-document-the-power-of-two-limitation-for-addr_unit.patch mm-damon-core-remove-damos_set_next_apply_sis-duplicates.patch mm-damon-core-use-time_before-for-next_apply_sis.patch mm-damon-core-use-time_after_eq-in-kdamond_fn.patch mm-damon-core-use-mult_frac.patch mm-damon-tests-core-kunit-add-a-test-for-damon_is_last_region.patch mm-damon-core-clarify-damon_set_attrs-usages.patch mm-damon-document-non-zero-length-damon_region-assumption.patch docs-admin-guide-mm-damn-lru_sort-fix-intervals-autotune-parameter-name.patch docs-mm-damon-maintainer-profile-use-flexible-review-cadence.patch docs-mm-damon-index-fix-typo-autoamted-automated.patch mm-damon-core-introduce-damos_quota_goal_tuner.patch mm-damon-core-allow-quota-goals-set-zero-effective-size-quota.patch mm-damon-core-introduce-damos_quota_goal_tuner_temporal.patch mm-damon-sysfs-schemes-implement-quotas-goal_tuner-file.patch docs-mm-damon-design-document-the-goal-based-quota-tuner-selections.patch docs-admin-guide-mm-damon-usage-document-goal_tuner-sysfs-file.patch docs-abi-damon-update-for-goal_tuner.patch mm-damon-tests-core-kunit-test-goal_tuner-commit.patch selftests-damon-_damon_sysfs-support-goal_tuner-setup.patch selftests-damon-drgn_dump_damon_status-support-quota-goal_tuner-dumping.patch selftests-damon-sysfspy-test-goal_tuner-commit.patch mm-damon-core-fix-wrong-end-address-assignment-on-walk_system_ram.patch mm-damon-core-support-addr_unit-on-damon_find_biggest_system_ram.patch mm-damon-core-support-addr_unit-on-damon_find_biggest_system_ram-fix.patch mm-damon-core-receive-addr_unit-on-damon_set_region_biggest_system_ram_default.patch mm-damon-core-receive-addr_unit-on-damon_set_region_biggest_system_ram_default-fix.patch mm-damon-reclaim-respect-addr_unit-on-default-monitoring-region-setup.patch mm-damon-lru_sort-respect-addr_unit-on-default-monitoring-region-setup.patch