From patchwork Fri Sep 9 20:28:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12972158 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 015A8ECAAD3 for ; Fri, 9 Sep 2022 20:29:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 89C178D0003; Fri, 9 Sep 2022 16:29:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 84B318D0002; Fri, 9 Sep 2022 16:29:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 73A428D0003; Fri, 9 Sep 2022 16:29:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 608108D0002 for ; Fri, 9 Sep 2022 16:29:08 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 29BC2A03DD for ; Fri, 9 Sep 2022 20:29:08 +0000 (UTC) X-FDA: 79893686376.24.6AE3BDB Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf28.hostedemail.com (Postfix) with ESMTP id C7271C00AA for ; Fri, 9 Sep 2022 20:29:07 +0000 (UTC) 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 D18B062031; Fri, 9 Sep 2022 20:29:06 +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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662755347; a=rsa-sha256; cv=none; b=kESzi2M1KjXAyWESN0QtQpgcYH+ktKjHMra8Xk7ZdU4xSuU2KrydlRQHPVKRplas9ZY8kW NJCTpIB2HEr6cqpjkR5FTvoWyu0OTDkKzQymw+Omsk8AboWVMiCX7qISPB3Adb9PR3K7W0 gfsGFSUitUTtyt0yjO8OrgTqwQIIsiI= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eA7mXHTj; spf=pass (imf28.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=1662755347; 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=KnSLIbchjvCYXR8yRecYEOIGYLhUlIpdciGflEDlDrM=; b=blcb3zU6KwKg9bXE46eJbuWLjWtzsBIPhWbwWCM+d2a2GJRVTZ0fUtaCwF5JqwC/pw0E1q dIwulS6SxqSOHl54nHP3QvcOZ2XAC92tKyGs+k8SF7Hfxw2+iUs+76FI8sluaz6sZuTA56 3hLRbow+LKxj6KSrQKKoecjLmVzTcCw= Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eA7mXHTj; spf=pass (imf28.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 X-Rspam-User: X-Stat-Signature: 89nmfqyixrngspm1t4agungimz34fswu X-Rspamd-Queue-Id: C7271C00AA X-Rspamd-Server: rspam01 X-HE-Tag: 1662755347-428009 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: 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), {}, };