damon.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
Cc: SeongJae Park <sj@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Brendan Higgins <brendanhiggins@google.com>,
	damon@lists.linux.dev, linux-mm@kvack.org,
	kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [RFC PATCH 5/8] mm/damon/core-test: add a unit test for the feedback loop algorithm
Date: Sun, 12 Nov 2023 19:46:04 +0000	[thread overview]
Message-ID: <20231112194607.61399-6-sj@kernel.org> (raw)
In-Reply-To: <20231112194607.61399-1-sj@kernel.org>

Implement a simple kunit test for testing the behavior of the core logic
of the goal-oriented feedback-driven DAMOS quota auto-tuning.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 mm/damon/core-test.h | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/mm/damon/core-test.h b/mm/damon/core-test.h
index f405d79dc623..c2b8cb25a195 100644
--- a/mm/damon/core-test.h
+++ b/mm/damon/core-test.h
@@ -447,6 +447,37 @@ static void damos_test_filter_out(struct kunit *test)
 	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),
@@ -463,6 +494,7 @@ static struct kunit_case damon_test_cases[] = {
 	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),
 	{},
 };
 
-- 
2.34.1


  parent reply	other threads:[~2023-11-12 19:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-12 19:45 [RFC PATCH 0/8] DAMOS: Introduce Aim-oriented Feedback-driven Aggressiveness Auto Tuning SeongJae Park
2023-11-12 19:46 ` [RFC PATCH 1/8] mm/damon/core: implement goal-oriented feedback-driven quota auto-tuning SeongJae Park
2023-11-12 19:46 ` [RFC PATCH 2/8] mm/damon/sysfs-schemes: implement scheme quota goals directory SeongJae Park
2023-11-12 19:46 ` [RFC PATCH 3/8] mm/damon/sysfs-schemes: commit damos quota goals user input to DAMOS quota auto-tuning SeongJae Park
2023-11-12 19:46 ` [RFC PATCH 4/8] mm/damon/sysfs-schemes: implement a command for scheme quota goals only commit SeongJae Park
2023-11-12 19:46 ` SeongJae Park [this message]
2023-11-12 19:46 ` [RFC PATCH 6/8] selftests/damon: test quota goals directory SeongJae Park
2023-11-12 19:46 ` [RFC PATCH 7/8] Docs/mm/damon/design: Document DAMOS quota auto tuning SeongJae Park
2023-11-12 19:46 ` [RFC PATCH 8/8] Docs/admin-guide/mm/damon/usage: update for quota goals SeongJae Park

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231112194607.61399-6-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=brendanhiggins@google.com \
    --cc=damon@lists.linux.dev \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).