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: 164280 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp840702vqg; Sun, 12 Nov 2023 11:47:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IEKzrnRmSnrLGreYN+w1fI6Jwt4IzDSlaiUQRD9tZir3j6pJIVRntafEHgOfZHTQb47pkoz X-Received: by 2002:a17:90b:1bc2:b0:280:8cef:c87d with SMTP id oa2-20020a17090b1bc200b002808cefc87dmr5267660pjb.19.1699818433493; Sun, 12 Nov 2023 11:47:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699818433; cv=none; d=google.com; s=arc-20160816; b=c8Bob4AxU6WfgZu72dV6AyGpd/RhLpHkdxBxvZgaiG0HxN5ZVnq6AnPzriu321x3FF Gjv60gnKzJv68jVNsIqXZtV5oiaud9Z1tx39a5I1pGyHBdSrTKkjSidwep1fw9Mf4zFz KwMminbyLENToIVBWK1dKSd5rBYBOiPQZdHx3K5MZ0+S7wzcDro2ALBPeGobLswmH1es O/ycooYiYynbbHGDB3hy5tYNzvTCGSYLR2M2Xr+sfdFFZclTXTHVNsRsf0woR8W8CHdC xSnGAeMVXVX5lzq25S+YHVe5ReJoY9q15gXmvoLtbxQNdas0yJKlYa6ncLx7nYZRxp6X FY+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=8360v2be9T2lgyjq9aBm32O9Ko2A7dDB6T7+GQjYV0Q=; fh=94uYpO7FLrgLLvAQT7RSjW70OHzxQpeK2ugekYHQA8k=; b=kW2bsbxxRg+RL1UjmBOqe4C+69hhawCpVDjYSUVd3I2wuMg4Rda81TEAirZmeWrhRS JzXDVJrd5CcyGhVn5CDIlHN8bdKwCXx5HHUigEOtAxwpFkkIs8vcQQ21Xkre8+U2Stny hQK4z+otLs4V4SmQexyN+y13e8cKyauxBstI77FmAjhOI6jTeTjkUtjt2MJK/XHdrSJA 3OF/ovnIdcFuv+c2qBX21Opo72GFunqXcZKBi/yQR5dXPII+ezI4OhdniIJADtbKkjRR fOhXyt5/f14BoVRw+Ruq8wedGCR4LQVvkmHqMdCy+hheeOk6V89WzDDlP/d6ZJ7SEQO4 zdjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=IZqjkc6F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id md17-20020a17090b23d100b0028105ba769fsi4017507pjb.149.2023.11.12.11.47.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Nov 2023 11:47:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=IZqjkc6F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id E3D7A804F62A; Sun, 12 Nov 2023 11:46:39 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232518AbjKLTqe (ORCPT + 30 others); Sun, 12 Nov 2023 14:46:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232176AbjKLTqT (ORCPT ); Sun, 12 Nov 2023 14:46:19 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 972E42139 for ; Sun, 12 Nov 2023 11:46:16 -0800 (PST) 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 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) 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 (snail.vger.email [0.0.0.0]); Sun, 12 Nov 2023 11:46:40 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782388813244664156 X-GMAIL-MSGID: 1782388813244664156 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), {}, };