Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp297901rwb; Wed, 18 Jan 2023 17:58:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXuxT69P+v3l9zxxUvUo6AZxYF5t020m4caBsSOcvRKuee1m8GqrfR2KjZc7uIMgBiI+ZAwK X-Received: by 2002:a17:902:e80e:b0:192:f281:b933 with SMTP id u14-20020a170902e80e00b00192f281b933mr12567177plg.9.1674093536205; Wed, 18 Jan 2023 17:58:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674093536; cv=none; d=google.com; s=arc-20160816; b=qopTMp/8Q/OR/rBNqoVAl09y6E6kdiUWC73HoE8yy3gfNjrtj9hx7zAxJa70QpHtFa GFRKl8N2z7qC/hLEUUAVHJqwsCzjZ69CJ1govooSTYKTc+TZIg2Q9EDEigqODFyw+UmO oGlVnsZoBR3tS/AZSSdWLJUBOdhqu1d/Id7HHu9e6Uk9g5ZgtiH0r3UfHQ3d+Rg0inCY KVLx/j6qmQUC0g/OE1QFkVrc4J2zPQnJihbGSuFq9l1b0I48vek36TrtWNhplOX7GXbo xJ6pGn02CBOmsneKI279GoQ8W9A8pCloRYCsFIGAG+6AXPyblnzID0DKJx/xPwH5pCdz EE3Q== 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=3fNupXQhsN5vsVTB6XW0C50NRNjjMAsS/7fTR58sXqA=; b=bmgpEKouJxWcx5Y3Lip6FcTcTvYwCHMgBGhcsTlRsxrirwnP1WMkNr8Zg52frPAb4i 9JDU8DE4R8BuMP4DVtIiVVBJIBGqU/Ee+X2uq3XwzP033MrJu+im7JXzK/2vqjH6k5to uuYAcQNhXJvBDjsjuiCtHgZrrrQm7HiviCXtdnt85VJaJa/RWv9/jdyn++cwIPxp6jMI Tksz77HFw/AJSkjUMKsVi924MyjS8HhxuulbL1iRXiJZKC3wLv5titr92HcKjxV31cLB OfmuKL+917UFiQjRe9crzqov1Yd4Lt/hVKUUeNcZNWKP/GpCbiko3T9o6UNH8rLo3Mr9 uEhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kg1+ilbz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e7-20020a170903240700b00170f6f728d4si35879206plo.543.2023.01.18.17.58.50; Wed, 18 Jan 2023 17:58:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kg1+ilbz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230140AbjASBtm (ORCPT + 44 others); Wed, 18 Jan 2023 20:49:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229960AbjASBpl (ORCPT ); Wed, 18 Jan 2023 20:45:41 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4E286CCC2 for ; Wed, 18 Jan 2023 17:38:40 -0800 (PST) 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 7480561781 for ; 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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), {}, }; -- 2.25.1