From patchwork Sun Nov 12 19:46:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13453385 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A9BAC4332F for ; Sun, 12 Nov 2023 19:46:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4ACE38D0020; Sun, 12 Nov 2023 14:46:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4374B8D001D; Sun, 12 Nov 2023 14:46:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2893B8D0020; Sun, 12 Nov 2023 14:46:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 0EB378D001D for ; Sun, 12 Nov 2023 14:46:22 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id DC6AF160115 for ; Sun, 12 Nov 2023 19:46:21 +0000 (UTC) X-FDA: 81450333762.24.ABD2FAE Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf15.hostedemail.com (Postfix) with ESMTP id D14A5A000C for ; Sun, 12 Nov 2023 19:46:19 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=IZqjkc6F; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf15.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699818380; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=8360v2be9T2lgyjq9aBm32O9Ko2A7dDB6T7+GQjYV0Q=; b=fhm18RwAZKT6VxyMC9Yxk5Lm7YlovFWNbJuTZhIpohmNqSTnYCaMprMJYyCK/3s/buyX0M GS88YzifpygbFQyz6dQRMKvinTLIS6oHqlSmg/grDYg0NrxkzVxXZrlayf0Kvjh30ee1P0 Au4zijhoU41x4q80GzLN2+v17GGnF/g= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=IZqjkc6F; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf15.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699818380; a=rsa-sha256; cv=none; b=zHkaneE/mPHbC6QuxBK11nV3YSKt25l3JXUDHKxX7wguGuu/Nnd21Mi7MxcTfVcHOvT8zB f17VWlgVrWjfprA5uyeVfnEjPFc52yfO84fFPqYh56izZafXYUy6ZrlmwoEn+i40LFk8iQ bq9l7qQApO2Ch2O4qdsHSh9pRUP2Q/w= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 0BFD6CE0EB3; Sun, 12 Nov 2023 19:46:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B47C7C433C9; Sun, 12 Nov 2023 19:46:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699818376; bh=aHVFSWkLgL3DSZk4BMjseldmOMFwERpUZXKvLSdezzE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IZqjkc6FTf18ZhcDORKrMuhByH+hD2Ss0jubtVf43EF5ai/X82RLUEbaKYzgzrYU9 z6lLO2EUuHLi77rriepOZl7QKtaMC8Lnri0kYl1PYU209QyxwYWYWi9JCcsCDjorSY nX7TWmp0x/LbG5ORpd0gvkGY5iZ3V4vgnl0FRXB+P9gnFbOn20pXo3jAaOlyD6rwT3 EMOH773xXOzjDJZwTk0G2KvHE4Vh6Lo3Loq7gL6WzItm5OgzbL5eYpkwesgfSh4aAc tfP0sImuju4Qi3qfRbyvnT60OF/mRJz+vhHo9fpIDgD5AGwY3tf9vxowqQUza3+BJo jkDyFPFq0/qnA== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , Brendan Higgins , 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 Message-Id: <20231112194607.61399-6-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231112194607.61399-1-sj@kernel.org> References: <20231112194607.61399-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: D14A5A000C X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: kgsns5maywr196nwaoybgfgyn5juased X-HE-Tag: 1699818379-205244 X-HE-Meta: U2FsdGVkX1/O0MGBC78eN0cEi9eqvhIUlX9YvntX9UuCjCsJ3z+RA8sMGYBLwNXwqCQ2sW3Aij/r6j9EWMb1rYcRsGvTz9mfXOn3NmUnAsh75AI0Uy/AcaOhzjayf9mZDNhxJw6Oewka/IoRmzIY/4QfghmGWzkXGF4zXHmzw+8Qz2+PDwfb6B3sJM4SVf2iomidaXZLYTfYHFZ9LROcr3GbWqIc2DlNKhTliSwVDJx8KyS/DVJhkNMUfX1PlIgTw+hCa2he2Ve0ZDvezJfPfmgl0EolRi7AjxxlP7PbkJnD4wUQlhRxjtz9q8gt53Rtl+3Q93sdbojNCnfxbIbqEIsUWgr1DhIbcv7lkUJ7iTZGdELPHSEkHi0ubQwS40yTSo6tM5v3wJichgoEHbBi77mhPuW1Oegt5yA+XlZzJ0gH9/79R30comNZjaXLY7+3zPT7j6VpAASoHpyYdStDmiR8VpQKC4HLjZa65wOes63f0BTMgA241G2N7bwRXT2TNi9Cms3fBzM5jJtZiPgsHBebGi/0NYxSQUTIaOW/B13pXtfjlgL25uHCVbRNH36rtpf68LYjqKreRTunl7hLSaEm9fSvku4w9Ske8b39g8/tmwO7D2KOkouoEV3HJ7n+uW82vzZsvRbe5Mvzq0r1Ijw77cEfnA09W55TyVbmSpDWgNS4j/EH13PwG3Qm9InG0GY6izcEiPmvmE+IAn3lUoS0J7mzA61qk5g5XYsgsoqADkwKwqkIk2EIV2YpSDsSSi4ASYkX47nV/0gBbErtgecbH36rW16Ri3gyf8ff4X1QE641vGmbIeIRt8jllAVIbDRnRYEi8AZxVxYhvs2iMiMw5QPtP9ffBSGDVIwMa3KsQEOD2z3huADNMMX1BSg2J7WmlK+zzHeW/Jf2HYA3qUbOHMPJMQreUo/Lqwi/krNGKwR8CSe2lhvkmHYDcm/SmQPPo7mjYjh9Gh22ddK x0fBTFgy RHR2LfmOPtjxOJjglZgkGpXFw+8LYIJYU5pc7R/5XGuQh2XuqbxSMhjI9xGzgIQamrHmTBdViU++BtZ2ljGCopMTd1sMwQt233jasyAPvaTeBHSqyj1lscQSSghoU7jAk1sh/+d6lc3o9yocm+4yKKgjnv+/3KIDv9IDsqhWYb4IVzciPfhrbw1raKSRgSqQAElr/zJD1qc63Jbf/ttDdvnsDwkoEiCKPLmlyS55xybPUTPc= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 --- 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), {}, };