Skip to contentSkip to conversation

mm-damon-core-remove-comment-and-test-for-nr_to_bp-divide-by-zero.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Aug 5

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm/damon/core: remove comment and test for nr_to_bp() divide-by-zero
has been removed from the -mm tree. Its filename was
mm-damon-core-remove-comment-and-test-for-nr_to_bp-divide-by-zero.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: remove comment and test for nr_to_bp() divide-by-zero
Date: Wed, 8 Jul 2026 06:53:51 -0700

Patch series "mm/damon: update probe hits for runtime parameter commits".

DAMON users can update DAMON parameters such as sampling and aggregation intervals at runtime. For such changes, monitoring results that depend on the intervals should be properly updated for better accuracy. For example, the access frequency counter (nr_accesses) is updated. The data attribute monitoring counter (probe_hits) is not being updated, though. Do the updates for new parameters.

Patch 1 removes obsolete comments and test code for a function that this series will touch. Patches 2-5 rename functions that are being used for nr_accesses update, to be able to be used for probe_hits without confusion. Patch 6 does the probe_hits update. Patch 7 update damon_probe_hits_mvsum() to cover a corner case from the update for better accuracy.

This patch (of 7):

The comments on damon_nr_accesses_to_accesses_bp() and its unit test warn it can trigger division-by-zero when the aggregation interval is zero. Commit 35d4a3cf70a8 ("mm/damon/ops-common: handle extreme intervals in damon_hot_score()") modified damon_max_nr_accesses() to always return non-zero. Hence no division-by-zero of the note can happen. Remove the obsolete comment on the function. The test code was written to test the division-by-zero case, which cannot happen anymore. Having it makes no sense. Entirely remove the test code and its comment.

---

 mm/damon/core.c             |    8 +-------
 mm/damon/tests/core-kunit.h |   23 -----------------------
 2 files changed, 1 insertion(+), 30 deletions(-)
mm/damon/core.c renamed from mm/damon/core.c~mm-damon-core-remove-comment-and-test-for-nr_to_bp-divide-by-zero +1 -7
@@ -883,13 +883,7 @@ static unsigned int damon_accesses_bp_to
 	return accesses_bp * damon_max_nr_accesses(attrs) / 10000;
 }
 
-/*
- * Convert nr_accesses to access ratio in bp (per 10,000).
- *
- * Callers should ensure attrs.aggr_interval is not zero, like
- * damon_update_monitoring_results() does .  Otherwise, divide-by-zero would
- * happen.
- */
+/* Convert nr_accesses to access ratio in bp (per 10,000) */
 static unsigned int damon_nr_accesses_to_accesses_bp(
 		unsigned int nr_accesses, struct damon_attrs *attrs)
 {
mm/damon/tests/core-kunit.h renamed from mm/damon/tests/core-kunit.h~mm-damon-core-remove-comment-and-test-for-nr_to_bp-divide-by-zero +0 -23
@@ -575,28 +575,6 @@ static void damon_test_set_regions(struc
 			}, 3);
 }
 
-static void damon_test_nr_accesses_to_accesses_bp(struct kunit *test)
-{
-	struct damon_attrs attrs = {
-		.sample_interval = 10,
-		.aggr_interval = ((unsigned long)UINT_MAX + 1) * 10
-	};
-
-	/*
-	 * In some cases such as 32bit architectures where UINT_MAX is
-	 * ULONG_MAX, attrs.aggr_interval becomes zero.  Calling
-	 * damon_nr_accesses_to_accesses_bp() in the case will cause
-	 * divide-by-zero.  Such case is prohibited in normal execution since
-	 * the caution is documented on the comment for the function, and
-	 * damon_update_monitoring_results() does the check.  Skip the test in
-	 * the case.
-	 */
-	if (!attrs.aggr_interval)
-		kunit_skip(test, "aggr_interval is zero.");
-
-	KUNIT_EXPECT_EQ(test, damon_nr_accesses_to_accesses_bp(123, &attrs), 0);
-}
-
 static void damon_test_update_monitoring_result(struct kunit *test)
 {
 	struct damon_attrs old_attrs = {
@@ -1572,7 +1550,6 @@ static struct kunit_case damon_test_case
 	KUNIT_CASE(damon_test_split_above_half_progresses),
 	KUNIT_CASE(damon_test_ops_registration),
 	KUNIT_CASE(damon_test_set_regions),
-	KUNIT_CASE(damon_test_nr_accesses_to_accesses_bp),
 	KUNIT_CASE(damon_test_update_monitoring_result),
 	KUNIT_CASE(damon_test_set_attrs),
 	KUNIT_CASE(damon_test_mvsum),

_

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