mm-damon-core-extend-merge-function-to-work-with-probe-hits.patch removed from -mm tree
The quilt patch titled
Subject: mm/damon/core: extend merge function to work with probe hits
has been removed from the -mm tree. Its filename was
mm-damon-core-extend-merge-function-to-work-with-probe-hits.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: SJ Park <[email protected]>
Subject: mm/damon/core: extend merge function to work with probe hits
Date: Fri, 10 Jul 2026 06:46:37 -0700
When probe weights are set, users may want DAMON monitoring results to be optimized for the weights. For that, regions adjustment should work for the weighted sum of probe hits. Extend damon_merge_regions_of() to detect if the weights are set, and work with probe hits in the case.
The weights setup detection function is incomplete. It always returns false. It is intentional, so that more changes to completely support weights can be made in an incremental but safe way. Until the function is completed, all changes depend on it is no-op, so DAMON works in the current mode.
---
mm/damon/core.c | 49 +++++++++++++++++++++++++++------- mm/damon/tests/core-kunit.h | 13 +++++++-- 2 files changed, 50 insertions(+), 12 deletions(-)
mm/damon/core.c renamed from mm/damon/core.c~mm-damon-core-extend-merge-function-to-work-with-probe-hits +39 -10
@@ -209,6 +209,11 @@ static struct damon_probe *damon_nth_proreturn NULL ; } +static bool damon_has_probe_weights (struct damon_ctx *c) +{ +return false; +} +/* * damon_mvsum() - Returns pseudo moving sum value for a time window. * @current_nr: The value of the current aggregation window.
@@ -3248,6 +3253,16 @@ static void damon_merge_two_regions(strudamon_destroy_region (r, t); } +static unsigned int damon_merge_score (struct damon_region *r,bool last, +struct damon_ctx *ctx,bool use_probe_hits) +{ +if (use_probe_hits) +return damon_probe_hits_wsum (r, last, ctx); +if (last) +return r->last_nr_accesses; +return r->nr_accesses; +} +/* * Merge adjacent regions having similar access frequencies *
@@ -3256,24 +3271,38 @@ static void damon_merge_two_regions(stru* sz_limit size upper limit of each region */ static void damon_merge_regions_of (struct damon_target *t,unsigned int thres, -unsigned long sz_limit) +unsigned long sz_limit,struct damon_ctx *ctx) {struct damon_region *r, *prev =NULL , *next; +bool use_probe_hits =damon_has_probe_weights (ctx);damon_for_each_region_safe (r, next, t) { -if (abs_diff (r->nr_accesses, r->last_nr_accesses) > thres) +unsigned int score, last_score, diff; + + score =damon_merge_score (r, false, ctx, use_probe_hits); + last_score =damon_merge_score (r, true, ctx, use_probe_hits); + +if (abs_diff (score, last_score) > thres) r->age =0 ; -else if ((r->nr_accesses ==0 ) != (r->last_nr_accesses ==0 )) +else if ((score ==0 ) != (last_score ==0 )) r->age =0 ;else r->age++; -if (prev && prev->ar.end == r->ar.start && -abs_diff (prev->nr_accesses, r->nr_accesses) <= thres && -damon_sz_region (prev) +damon_sz_region (r) <= sz_limit) -damon_merge_two_regions (t, prev, r); -else - prev = r; +if (!prev) + goto set_prev_continue; +if (prev->ar.end != r->ar.start) + goto set_prev_continue; + diff =abs_diff (score,damon_merge_score (prev, false, ctx, + use_probe_hits)); +if (diff > thres) + goto set_prev_continue; +if (damon_sz_region (prev) +damon_sz_region (r) > sz_limit) + goto set_prev_continue; +damon_merge_two_regions (t, prev, r); +continue ; +set_prev_continue: + prev = r; } }
@@ -3306,7 +3335,7 @@ static void kdamond_merge_regions(struct do { nr_regions = 0; damon_for_each_target(t, c) { - damon_merge_regions_of(t, threshold, sz_limit); + damon_merge_regions_of(t, threshold, sz_limit, c); nr_regions += damon_nr_regions(t); } threshold = max(1, threshold * 2);
mm/damon/tests/core-kunit.h renamed from mm/damon/tests/core-kunit.h~mm-damon-core-extend-merge-function-to-work-with-probe-hits +11 -2
@@ -226,6 +226,7 @@ static struct damon_region *__nth_regionstatic void damon_test_merge_regions_of (struct kunit *test) { +struct damon_ctx *ctx;struct damon_target *t;struct damon_region *r;unsigned long sa[] = {0 ,100 ,114 ,122 ,130 ,156 ,170 ,184 ,230 };
@@ -236,20 +237,27 @@ static void damon_test_merge_regions_of(unsigned long eaddrs[] = {112 ,130 ,156 ,170 ,230 ,10170 };int i; + ctx =damon_new_ctx (); +if (!ctx) +kunit_skip (test,"ctx alloc fail" ); + t =damon_new_target (); -if (!t) +if (!t) { +damon_destroy_ctx (ctx);kunit_skip (test,"target alloc fail" ); + }for (i =0 ; i <ARRAY_SIZE (sa); i++) { r =damon_new_region (sa[i], ea[i]);if (!r) {damon_free_target (t); +damon_destroy_ctx (ctx);kunit_skip (test,"region alloc fail" ); } r->nr_accesses = nrs[i];damon_add_region (r, t); } -damon_merge_regions_of (t,9 ,9999 ); +damon_merge_regions_of (t,9 ,9999 , ctx);/* 0-112, 114-130, 130-156, 156-170, 170-230, 230-10170 */ KUNIT_EXPECT_EQ (test,damon_nr_regions (t),6u );for (i =0 ; i <6 ; i++) {
@@ -258,6 +266,7 @@ static void damon_test_merge_regions_of(KUNIT_EXPECT_EQ (test, r->ar.end, eaddrs[i]); }damon_free_target (t); +damon_destroy_ctx (ctx); }static void damon_test_split_regions_of (struct kunit *test)
_
Patches currently in -mm which might be from [email protected] are
mm-damon-adjust-isolated-pages-stat-for-damos_migrate_hotcold.patch samples-damon-mtier-error-out-for-zero-quota-goal-target-values.patch mm-damon-lru_sort-error-out-for-10000-active_mem_bp.patch mm-damon-reclaim-skip-damon_call-if-ctx-has-not-started.patch mm-damon-lru_sort-skip-damon_call-if-ctx-has-not-started.patch mm-damon-core-skip-aging-from-repeated-aggressive-merging.patch mm-damon-core-hide-private-damon_region-fields.patch mm-damon-core-hide-private-damon_target-fields.patch mm-damon-core-hide-private-damos_quota_goal-fields.patch mm-damon-core-hide-private-damos_quota-fields.patch mm-damon-core-hide-private-damos_filter-fields.patch mm-damon-core-hide-private-damos-fields.patch mm-damon-core-hide-private-damon_filter-fields.patch mm-damon-core-hide-private-damon_probe-fields.patch mm-damon-sysfs-do-not-directly-access-damon_ctx-ops.patch mm-damon-core-hide-core-private-damon_ctx-fields.patch mm-damon-core-avoid-infinite-kdamond_merge_regions-internal-loop.patch mm-damon-tests-core-kunit-catch-test-failure-in-test_merge_regions_of.patch mm-damon-vaddr-drop-last-same-folio-access-check-optimization.patch mm-damon-paddr-drop-last-same-folio-access-check-reuse-optimization.patch mm-damon-sysfs-read-addr_unit-only-once-in-damon_sysfs_apply_inputs.patch mm-damon-sysfs-read-ops_id-only-once-in-damon_sysfs_apply_inputs.patch mm-damon-core-initialize-damos-last_applied.patch mm-damon-core-kunit-check-region-count-before-testing-in-split_at.patch mm-damon-vaddr-kunit-check-region-count-in-three_regions-test.patch mm-damon-core-kunit-handle-region-split-failure-in-filter_out.patch mm-damon-core-kunit-skip-wrong-dest-walk-in-commit_dests_for.patch mm-damon-core-kunit-skip-wrong-quota-goal-walk-in-commit_quota_goals.patch mm-damon-core-kunit-skip-wrong-region-walk-in-commit_target_regions.patch mm-damon-ops-common-use-nr_accesses-moving-sum-for-quota-score.patch mm-damon-core-handle-region-split-failure-in-apply_min_nr_regions.patch