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: 171703 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp113981vqy; Wed, 29 Nov 2023 18:38:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IE9Mg3iZPAI0oASAiRwpw2DnTGfrxg07xEcDOyaf36KCk92n0UfVnDzE1Xot3NCUuuS3K0K X-Received: by 2002:a17:90b:1d11:b0:27c:fc2a:a178 with SMTP id on17-20020a17090b1d1100b0027cfc2aa178mr24442677pjb.9.1701311934396; Wed, 29 Nov 2023 18:38:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701311934; cv=none; d=google.com; s=arc-20160816; b=TG47OlHNs7astOeJ0cZTX03Ptb55B9fEIDxYOMsh8qI7Sc7eMB7AzXE/2G7rnK7cVk xNMtSxIiWwOlPXnLJdtqeI8wIbX1gVBOhxm9hrAyVzLrA1IxmOa0e+aowi1Or6bolnz4 XK+25QmTFqkeWhutGaTjRUSqs1ZeQhwZ4fdy2yvKJ1hqOu/eTiKcXrwnQafR43w9ue41 IAs5TyY7303Yv2EPh3w1nopo1bqgSR+HxHcXfcCS/qmZt/fw3+F9zjPk2HxCR8M231tP J3T6rtD5J+iMqKfcdyQi2Co7x0g7DCGtUqdpwUy6PvE8sE8L2GkKyM5+Pu7H5eQvPUj7 dfrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SV91sbKHpchOuwEkTdeSfSLk3e2/GvbItb+/LWvupeM=; fh=yShER6sAU1t2EUnKfsE5D0X+v9il5RZ0sMRx2SrxMeQ=; b=UkO+lMTCHuVEFZX3k/J51BdYZuNCJDOAAvwct7eq1P61Z6haKKFLSMB3cHibS0uQ18 ztXFpsX4zuEW1GAWSgxeDgi86jYjxeYOn4qZZJmvAjZEigsxCYWgK/qjzuW6M35oYTcG Gw7X2ytLSHogwWfahegAk37GtlzHF1ULrQg1WRz1AGOcjIIaZP+0oPDqzkGlxcVJNxmQ 3JEwIIOh4KJCmpE2nHE3TITzNMpqcMewMX35arj0C1hw3ZvgLR+LF5myGVFphWLDLp2b /jcw7+ek0CbdzU14Ezffk8/cT2nT+Z//oHhlQFMr3QZsvg7+QL9OtRilxupxWglpegHb lFpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z6+6tCLI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id fu1-20020a17090ad18100b0028516fe2bffsi2393307pjb.186.2023.11.29.18.38.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 18:38:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z6+6tCLI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 5E2A3801C81A; Wed, 29 Nov 2023 18:38:47 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234973AbjK3CiL (ORCPT + 99 others); Wed, 29 Nov 2023 21:38:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235009AbjK3CiA (ORCPT ); Wed, 29 Nov 2023 21:38:00 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF17510FF for ; Wed, 29 Nov 2023 18:37:34 -0800 (PST) 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-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 29 Nov 2023 18:38:47 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783954862799470010 X-GMAIL-MSGID: 1783954862799470010 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), {}, };