Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp2422509rwn; Fri, 9 Sep 2022 13:32:45 -0700 (PDT) X-Google-Smtp-Source: AA6agR7SxwGE29nwTMRZbtQzx6aGIlMHTQUwvIv/gUSOc6u8M1wTSg2Lw+FPUEgS2r5udz2XyuTb X-Received: by 2002:a17:907:9495:b0:73c:b19e:ce06 with SMTP id dm21-20020a170907949500b0073cb19ece06mr11079833ejc.559.1662755565567; Fri, 09 Sep 2022 13:32:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662755565; cv=none; d=google.com; s=arc-20160816; b=CkUFuSDGEC69K4+lxD6FUpjIAQ8jtExmVBnIAAQBHV4UJSHLnaohsT1jmHkPkghdTQ v2j1Ysgv+mJ2/0aKKpFFF7CRnxBCP2I8ZABKqZMzFH6BudzdoSBc0LZqa7ZhdWN/ttIb Nfsll1J8Bgnb4+5+Bq+YLqIALYrb1g0arYByF72zSf2D7946O7NvWTD7OqGNLyOjL/AP 8zd2114WgdKzUp+pVn/HQgrriqitn+Xh6iptDtXAEfD/zZ2wm/xF1deEZ24ZbPdB2EJw XkNhASTU+FeNwXmlIdV7ajhdYWNIzSa1IJuGy95pq96H5fPoHGEGihTl/3eF+JgHs506 hlaA== 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=KnSLIbchjvCYXR8yRecYEOIGYLhUlIpdciGflEDlDrM=; b=ZRnhP7KPKHShUZ9aNDP9Qw+rIeUf3w1KXTFDbzJ0vthcsWDeIhsuAESWV42u0rWRf3 Ya3aBP7Lklvxm5jME14xGA3qWdXwJheIsZugAM/tpXZoUgu9sg62EpbU/FhxxKxH+DIo bHOw63/gT8aBIT5g7ahxO6/bgJOTLPcNFrr9pvlMEb7kmPwUAJ8dc0Y2zBV477ZBN4Cy PJGGIHSet+RB/P+fmPP5v2EEmx7Wd1EU4QUqG4y+h3evPCXtfuLnPugYrl5HYzGSh44h 1Wo+9fc6aCWglE1gGXF0drfVGoPiw/ybQFQCiJoZcs9Y82/XtrBlUPM7nnPcDsDvhU9i 9eMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eA7mXHTj; 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 di12-20020a170906730c00b00779bfd92c85si1561261ejc.10.2022.09.09.13.32.20; Fri, 09 Sep 2022 13:32:45 -0700 (PDT) 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=eA7mXHTj; 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 S232304AbiIIUal (ORCPT + 99 others); Fri, 9 Sep 2022 16:30:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230338AbiIIU35 (ORCPT ); Fri, 9 Sep 2022 16:29:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7E8F13FA7F for ; Fri, 9 Sep 2022 13:29:08 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 80CEAB82654 for ; Fri, 9 Sep 2022 20:29:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8795C43140; Fri, 9 Sep 2022 20:29:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662755346; bh=sDNPmkLNtbffCB7yBaG1vDK4L/fqo+2nXKmiK+SjhXs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eA7mXHTj8CAzo/dRgZSWiewM44BtCMTaJAUI9iyDT9w6sOiNgjuaUS2ZfVGYovW7E 9k6WBRLbxhAiHv9bHVh/qo5r0lg4YESkE3zkAK7pzw+NywcHTJEMEqgrfERvlidZ0A LPIMksQdov+1IBnQnEiQIzijc8XrHiowTTfHfasQbD/gd74RFUHCtEMutN29RSDhao TPg8Du/HzkL4FuSyu7EasSyO8eaEUBMaBnLUnVGpfDTL0EJIH7gftvsq+SJoAd30Eh 9/HCo1PD50vk1Cgy09CIiTs6Rh5mNuxmqIgbYOvkf/X4aEuXCLI+uc90DVpznw4k9Z 5cToMONkW4Gzw== From: SeongJae Park To: Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 3/7] mm/damon/core-test: test damon_set_regions Date: Fri, 9 Sep 2022 20:28:57 +0000 Message-Id: <20220909202901.57977-4-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220909202901.57977-1-sj@kernel.org> References: <20220909202901.57977-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,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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Preceding commit fixes a bug in 'damon_set_regions()', which allows holes in the new monitoring target ranges. This commit adds a kunit test case for the problem to avoid any regression. Signed-off-by: SeongJae Park --- mm/damon/core-test.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/mm/damon/core-test.h b/mm/damon/core-test.h index 45db79d28fdc..3db9b7368756 100644 --- a/mm/damon/core-test.h +++ b/mm/damon/core-test.h @@ -267,6 +267,28 @@ static void damon_test_ops_registration(struct kunit *test) KUNIT_EXPECT_EQ(test, damon_register_ops(&ops), -EINVAL); } +static void damon_test_set_regions(struct kunit *test) +{ + struct damon_target *t = damon_new_target(); + struct damon_region *r1 = damon_new_region(4, 16); + struct damon_region *r2 = damon_new_region(24, 32); + struct damon_addr_range range = {.start = 8, .end = 28}; + unsigned long expects[] = {8, 16, 16, 24, 24, 28}; + int expect_idx = 0; + struct damon_region *r; + + damon_add_region(r1, t); + damon_add_region(r2, t); + damon_set_regions(t, &range, 1); + + KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 3); + damon_for_each_region(r, t) { + KUNIT_EXPECT_EQ(test, r->ar.start, expects[expect_idx++]); + KUNIT_EXPECT_EQ(test, r->ar.end, expects[expect_idx++]); + } + damon_destroy_target(t); +} + static struct kunit_case damon_test_cases[] = { KUNIT_CASE(damon_test_target), KUNIT_CASE(damon_test_regions), @@ -276,6 +298,7 @@ static struct kunit_case damon_test_cases[] = { KUNIT_CASE(damon_test_merge_regions_of), KUNIT_CASE(damon_test_split_regions_of), KUNIT_CASE(damon_test_ops_registration), + KUNIT_CASE(damon_test_set_regions), {}, }; -- 2.25.1