From patchwork Thu Jan 19 01:38:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13107283 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 70EAEC678D4 for ; Thu, 19 Jan 2023 01:38:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D08706B0074; Wed, 18 Jan 2023 20:38:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C8F6C6B0075; Wed, 18 Jan 2023 20:38:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B07D36B0078; Wed, 18 Jan 2023 20:38:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 9FEE06B0075 for ; Wed, 18 Jan 2023 20:38:42 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 74056C02D0 for ; Thu, 19 Jan 2023 01:38:42 +0000 (UTC) X-FDA: 80369839284.10.FD716B7 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf29.hostedemail.com (Postfix) with ESMTP id 0289A120002 for ; Thu, 19 Jan 2023 01:38:40 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=kg1+ilbz; spf=pass (imf29.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=1674092321; 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=3fNupXQhsN5vsVTB6XW0C50NRNjjMAsS/7fTR58sXqA=; b=E62lphBd9YzzEP7euHP90PUhX26WYKkKt6Rx6J1fHl2lhxThCxyxsH9bXINoWgucfQcaq0 KBqsvZHtwpGlkjArRIl3P+sqV4DHepM8LvvMZLugJvB1T7T7aqxRUU13/GGz/Ga2TX2K3U pVN5/tW5SrSsDOsWIpCpbmQYM7I7vNM= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=kg1+ilbz; spf=pass (imf29.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674092321; a=rsa-sha256; cv=none; b=j9Ma1VX6AbVoW5BgVAzGtgmEF7cCXpQc7UgYMIqgunQEorc6198HMX3GvjNPM1W6EWd3J1 97ufDI1GJhCJ39c4Slo3ysTF6WNbvF9Isjh0LDfQqE0KCJhJ3B/tBP0MCARpYzk5lx1rDh FJmjBt3sS2DiG6PI5iGTtqVXcFMZfe0= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 137046171D; Thu, 19 Jan 2023 01:38:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 640F5C43396; Thu, 19 Jan 2023 01:38:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674092319; bh=4x0hnDy4BX61lB/pbgUpUZC1nSP8lE0d4hLy0MishdY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kg1+ilbzWZybIQkILRS0j625AZhP7sNVWI2JBN+aHXZ2odIdbzI0kIXodhRrbj8ig ZMlQ4qeSzaSsYFpuRnzk1VeYWQRxyj3bxvcHY4BsmNvGwxGvezui3C/8oY8XHTfMr1 riwUIv17ty8xmzBgdHfrQcUrlhG/vmLian0Hf13hjJTOKFHuNoMjtcPWMyym5tVu2W Z2l+vaKdgROZU4t5MbhLxAXrs0ziF63YtDE1YtWY33j47VgUn7nJ579EToCzI5pPi+ ETtxqdK8+Gl28xqf7e28CIgB8kJEL99OCQ7yiOS28Z5gqgwE3vjfd2dFLeexDvyU9g HDsnVYKUsQkew== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , brendanhiggins@google.com, kunit-dev@googlegroups.com, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] mm/damon/core-test: add a test for damon_update_monitoring_results() Date: Thu, 19 Jan 2023 01:38:31 +0000 Message-Id: <20230119013831.1911-4-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230119013831.1911-1-sj@kernel.org> References: <20230119013831.1911-1-sj@kernel.org> MIME-Version: 1.0 X-Stat-Signature: y1argy464g8dpbsb8xfxieungh3z83bf X-Rspam-User: X-Rspamd-Queue-Id: 0289A120002 X-Rspamd-Server: rspam06 X-HE-Tag: 1674092320-821718 X-HE-Meta: U2FsdGVkX19auubuyx9brVTzQYOw/Ir0bubQ5A+9zszM536VAdt69Acnm4umufhDc3MUM8p9qe5YWJ0BhRSZStrWf6eQ7QbbSMFhVRRADeibS9hDADz4hSdlAhkxRJD/dsjdxAaS4FOaONUWn+9G2+BsdjF8lnGLP23j4WBzEzib8rnk1zFhQ5X1G4/Pl5+FvyfihgBAVtzqKce5Mg3DNsbJWGOXiB1fYjk2g+1wvH2IJ1+jn5jdOd3t+1gyi2NbwDFK0HnGqp0pQHILUf/YEfGWnrHH0RksGOBfK3wiPQiP05p1M7DPt49OK+4XH0W0ZVhciO8cTElSsvnLxRNe9R4HQ3hSFuRYREiiFYTR2ORLKsI42K4HDds4GnM1y0kxP2NpuaKZFVEztbE7+tPA1RPW4QP3ZHlq1yVm6PtgDarx1TyH7nzvKBp2rjB3JsS3o5VYNOBJvSWS8+QxQMw2F7xzqnJdnv8Yv1vxYg3yI7x79c8rVY7sQR209VdyXyr6d9Jgb0kYVh5YiLN+oxsJLMVUKBdcM6ckmwOqopvXk+ZtNN6l7VMVxi+KYvSLKG8wESUKOILwND0vRec8FZ2UBxdy3rgSfDaMCDKJYdTKr6Tf8j7neH4e2VCUwkiHBZd542lDUNCMdg/LMs9iTMgWb1PA9TvhJ4wkYdwcR+UqlqotvosZ/wTA+LZ81JKWcwJV7uitbvlJJz/TDrUpDw08PGvOGHUsMC29ZQzFyVtuSiEvjsaQGj3wyfpiVkHWpYJR2DroT6U9qUVObuf+l4NnUDOM6WS2SWuXd669LjktK/0BiBLg8vxz4rAG5CrR6Y0Y9qRSwygi7LU2E3sUuV1gjPtQRnWKB3inkpSO/Dj4H1BnneKZ9cV7QxFA5WavJ2E7etlPcRiOGbv2h3pgZJ1uMTWaCvJZldV01DPgDtrqjbpVY1UYIDBngUYjCF1TY7RH86XgxuFpz8K4gLsAh9q WS1O9QwT lIDNgTq96I2/qGmCnXpsaItiJO0SjZgyUn+vNnws4AwTe0q202uPysNrdzHzHMCB5JCIdX2hGZVFkgusDB3kVX0Ohx0g7sked4HInBwFpcg3kZmUd13XSgzhsog== 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: Add a simple unit test for damon_update_monitoring_results() function. Signed-off-by: SeongJae Park --- mm/damon/core-test.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/mm/damon/core-test.h b/mm/damon/core-test.h index 3db9b7368756..fae64d32b925 100644 --- a/mm/damon/core-test.h +++ b/mm/damon/core-test.h @@ -289,6 +289,35 @@ static void damon_test_set_regions(struct kunit *test) damon_destroy_target(t); } +static void damon_test_update_monitoring_result(struct kunit *test) +{ + struct damon_attrs old_attrs = { + .sample_interval = 10, .aggr_interval = 1000,}; + struct damon_attrs new_attrs; + struct damon_region *r = damon_new_region(3, 7); + + r->nr_accesses = 15; + r->age = 20; + + new_attrs = (struct damon_attrs){ + .sample_interval = 100, .aggr_interval = 10000,}; + damon_update_monitoring_result(r, &old_attrs, &new_attrs); + KUNIT_EXPECT_EQ(test, r->nr_accesses, 15); + KUNIT_EXPECT_EQ(test, r->age, 2); + + new_attrs = (struct damon_attrs){ + .sample_interval = 1, .aggr_interval = 1000}; + damon_update_monitoring_result(r, &old_attrs, &new_attrs); + KUNIT_EXPECT_EQ(test, r->nr_accesses, 150); + KUNIT_EXPECT_EQ(test, r->age, 2); + + new_attrs = (struct damon_attrs){ + .sample_interval = 1, .aggr_interval = 100}; + damon_update_monitoring_result(r, &old_attrs, &new_attrs); + KUNIT_EXPECT_EQ(test, r->nr_accesses, 150); + KUNIT_EXPECT_EQ(test, r->age, 20); +} + static struct kunit_case damon_test_cases[] = { KUNIT_CASE(damon_test_target), KUNIT_CASE(damon_test_regions), @@ -299,6 +328,7 @@ static struct kunit_case damon_test_cases[] = { KUNIT_CASE(damon_test_split_regions_of), KUNIT_CASE(damon_test_ops_registration), KUNIT_CASE(damon_test_set_regions), + KUNIT_CASE(damon_test_update_monitoring_result), {}, };