The patch titled Subject: mm/damon/core-test: add a unit test for the feedback loop algorithm has been added to the -mm mm-unstable branch. Its filename is mm-damon-core-test-add-a-unit-test-for-the-feedback-loop-algorithm.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-damon-core-test-add-a-unit-test-for-the-feedback-loop-algorithm.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: SeongJae Park <sj@xxxxxxxxxx> Subject: mm/damon/core-test: add a unit test for the feedback loop algorithm Date: Thu, 30 Nov 2023 02:36:48 +0000 Implement a simple kunit test for testing the behavior of the feedback loop algorithm for the aim-oriented feedback-friven DAMOS aggressiveness auto tuning. Link: https://lkml.kernel.org/r/20231130023652.50284-6-sj@xxxxxxxxxx Signed-off-by: SeongJae Park <sj@xxxxxxxxxx> Cc: Brendan Higgins <brendanhiggins@xxxxxxxxxx> Cc: David Gow <davidgow@xxxxxxxxxx> Cc: Jonathan Corbet <corbet@xxxxxxx> Cc: Shuah Khan <shuah@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/damon/core-test.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) --- a/mm/damon/core-test.h~mm-damon-core-test-add-a-unit-test-for-the-feedback-loop-algorithm +++ a/mm/damon/core-test.h @@ -446,6 +446,37 @@ static void damos_test_filter_out(struct damos_free_filter(f); } +static void damon_test_feed_loop_next_input(struct kunit *test) +{ + unsigned long last_input = 900000, current_score = 200; + + /* + * If current score is lower than the goal, which is always 10,000 + * (read the comment on damon_feed_loop_next_input()'s comment), next + * input should be higher than the last input. + */ + KUNIT_EXPECT_GT(test, + damon_feed_loop_next_input(last_input, current_score), + last_input); + + /* + * If current score is higher than the goal, next input should be lower + * than the last input. + */ + current_score = 250000000; + KUNIT_EXPECT_LT(test, + damon_feed_loop_next_input(last_input, current_score), + last_input); + + /* + * The next input depends on the distance between the current score and + * the goal + */ + KUNIT_EXPECT_GT(test, + damon_feed_loop_next_input(last_input, 200), + damon_feed_loop_next_input(last_input, 2000)); +} + static struct kunit_case damon_test_cases[] = { KUNIT_CASE(damon_test_target), KUNIT_CASE(damon_test_regions), @@ -461,6 +492,7 @@ static struct kunit_case damon_test_case KUNIT_CASE(damon_test_moving_sum), KUNIT_CASE(damos_test_new_filter), KUNIT_CASE(damos_test_filter_out), + KUNIT_CASE(damon_test_feed_loop_next_input), {}, }; _ Patches currently in -mm which might be from sj@xxxxxxxxxx are mm-damon-core-copy-nr_accesses-when-splitting-region.patch mm-damon-sysfs-schemes-add-timeout-for-update_schemes_tried_regions.patch mm-damon-core-test-test-damon_split_region_ats-access-rate-copying.patch mm-damon-core-implement-goal-oriented-feedback-driven-quota-auto-tuning.patch mm-damon-sysfs-schemes-implement-files-for-scheme-quota-goals-setup.patch mm-damon-sysfs-schemes-commit-damos-quota-goals-user-input-to-damos.patch mm-damon-sysfs-schemes-implement-a-command-for-scheme-quota-goals-only-commit.patch mm-damon-core-test-add-a-unit-test-for-the-feedback-loop-algorithm.patch selftests-damon-test-quota-goals-directory.patch docs-mm-damon-design-document-damos-quota-auto-tuning.patch docs-abi-damon-document-damos-quota-goals.patch docs-admin-guide-mm-damon-usage-document-for-quota-goals.patch