From patchwork Thu Nov 30 02:36:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13473978 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 72473C4167B for ; Thu, 30 Nov 2023 02:37:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CD0506B03AD; Wed, 29 Nov 2023 21:37:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C7E756B03AE; Wed, 29 Nov 2023 21:37:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B46C06B03DE; Wed, 29 Nov 2023 21:37:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A04176B03AD for ; Wed, 29 Nov 2023 21:37:05 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 69F7AA06EC for ; Thu, 30 Nov 2023 02:37:05 +0000 (UTC) X-FDA: 81513058410.23.F72367C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf07.hostedemail.com (Postfix) with ESMTP id B56FE40003 for ; Thu, 30 Nov 2023 02:37:03 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Z6+6tCLI; spf=pass (imf07.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701311823; 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=SV91sbKHpchOuwEkTdeSfSLk3e2/GvbItb+/LWvupeM=; b=f1tewJL0eTrHevfWAHiAb/g0CvBxCLHntzBNAeUDH7KEfxZ7EcBIl5VmCr3lg1AuPxsdfM AALEP8sk+rpyrgnf0rbRSFSe6qrgRjN8D/8IAU7p11xnR+s8YXgG+COfbnHKa47NWOElNg Ux1WnxCEva4PVeo96j7XXADAO2cEkV8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701311823; a=rsa-sha256; cv=none; b=mFAK2VF5vB3glIiouNhNtDHLf00PEznv7UMGJ3Q8CB9TX/lc6lQJ5iUHGeSR29fe81rSt6 nb2BfhKbD8gyyjH0S8gg0oSbeD3vj10BNPosQVkZnZCclptC+/OARgPw/NkwhV2d+mp/sx 9pTDbhj887y/SK6+ZS8GTeUUw2BKMUY= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Z6+6tCLI; spf=pass (imf07.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 04A876190B; Thu, 30 Nov 2023 02:37:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1AC1AC433CC; Thu, 30 Nov 2023 02:37:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701311822; bh=EtcCE3aKL92GHTdnkP2hxrtGMR/ShXKbIT2mRyd4U4A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z6+6tCLIAdAhswg3GRnBOLmuTKm3/4K740cV/qZXqJeePCyk2PGDIM6hlz0JUF59h CwnfWJGwv/ma6uevYQizY7w2KoKUhBrqhYWeTl81RNPi8QNGZA710/IYqgNHFbpUFW jJ+B1MncEdyn4JY3Jr0tTxCUn4DI6onqGmUXvzSH9tCs5RBeYcbVXy2FIVA1Bx5Wx5 perHVTael5dUoP8C/cTLFdstUUTFfXURD7Yc5WTb/uyFBVMRv/1jHhviCMBe00BkaS hfRoAuBG2WvyMptpLHFtLh1Hly+Atkns970LzE3OI3+Bb6MT12dFC25mvAtidZSgUH qwYEgT3+dO6Xg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Brendan Higgins , David Gow , damon@lists.linux.dev, linux-mm@kvack.org, kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/9] mm/damon/core-test: add a unit test for the feedback loop algorithm Date: Thu, 30 Nov 2023 02:36:48 +0000 Message-Id: <20231130023652.50284-6-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231130023652.50284-1-sj@kernel.org> References: <20231130023652.50284-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: B56FE40003 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: jzh8o6hwga31rsj6wrn7ztgn8h8e68jf X-HE-Tag: 1701311823-964953 X-HE-Meta: U2FsdGVkX18ZpPGWlzLtWDLueznxF5BT8g3qAXexD7HfNi0+gCsoLiR86QDvPWx+XIFMLIEu0s0Nmwa6FCuDLxhWc5E+tg3NpiYIL4/S9bvBqU/rPX6ScktFyjTFJJJ5m41PDQFKiE7+lh8qtMXUU6BRr+GBgDtJX5AoWuzcvFtSrr9YHuHooUQ9L5k3X0XP9bEGkzXDSqyHSKwJbEx1+2Sozyv6qlzpd5lH/SXDAxHLxaKXzbFwsQKJRKOylflSgiyi8+C439GQY9wRHeDDmE5G3lNYgUGebJDPuvrKvarUSXrYrpjL3605X9PHi530F6orRVEdnOO3FfeCHqR+JzeK2H7EUpUjp78HHJcYmeeRfPqV1rlDvZOk4hcL0ozh/2dqfuNIvjmTbFM/EoQKFr3lDn+gt0Lo39Di9dPTewjHRrbM+mN2Y8AEBQKAFIWjz+WabZo90/bxBx5+nIR+DccEydbtUKSEY41dVmfEgpx4+U+TWryhruptrH6BNbQIsX8wgXc5ZOkApppeQRXITYZobnIDdtLLkrbPme9q064ztuZHRzvgQZd4pVAQZ7TUQzTdmgfRDOl0I1FpEoXlCm22noyVdfha+20iZk9kmydi64VjtuXKwUR5uNQTHLzWLC8iK6YdxipfqAfa96NdljL0nlRN9ufly6ZTiqWhhEsaOs2RpWdfwkQzf2cPeKbRMXJtDC7R0rC1gbe44UURa4Fxkc7b9zAxSt/UYhxL4hVOhQsj4iY75rzO9lGqupepLqDvM9RbFfkqtneO/fk1oXi2uP4FuZZ0yUIVAnIUoYxMHBWv41/WSKqO7ufGGrJDR636Ql3uiGfswvzpRtR4WFDVwn+GNVqz6qMrYdkw1QK35xIOtEvEmigZW3uD7NArO4lZcjo4y8u8/vjaJp5jPv1GfPEMPn2l68ALyaMd5amPJXkoKdbUBjuojhg59X5xKSyvoo+phpJD+jwP9CD 2Av2uZsO aHZ1NYVrY7YqVWA7zZDHK8+sEmuWhnfnnsS8kxBmbQLcgBtLUkn3P2KJtvQmTzdgXJk8fcYEJ1shS7B/DsElA9bupBB1KodT3jrIKOjaoBbCaCb1/ppSkM+j7WOrkAxMIL6WnU2KpvwchqwV9fEche0wEk4WxkqIqd0ovloIeQWB7sPbS52k4NdDwYqccEI8om3Mh+YpbGbdZUA3vg3JxcFpSz8ktakVCCyIScgUlQBDEbxdVrFOLXn0zcg== 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 feedback loop algorithm for the aim-oriented feedback-friven DAMOS aggressiveness 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 e6a01ea2ec54..6e5e9502d648 100644 --- a/mm/damon/core-test.h +++ b/mm/damon/core-test.h @@ -446,6 +446,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), @@ -461,6 +492,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), {}, };