From patchwork Tue Aug 27 03:03:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13778781 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 4AC68C5321D for ; Tue, 27 Aug 2024 03:03:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 44CF66B0085; Mon, 26 Aug 2024 23:03:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 369746B0088; Mon, 26 Aug 2024 23:03:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FEB96B0089; Mon, 26 Aug 2024 23:03:52 -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 EA0A16B0085 for ; Mon, 26 Aug 2024 23:03:51 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 96A841A157D for ; Tue, 27 Aug 2024 03:03:51 +0000 (UTC) X-FDA: 82496530662.04.15F7D4F Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf08.hostedemail.com (Postfix) with ESMTP id 07E3816001C for ; Tue, 27 Aug 2024 03:03:49 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eClTrHDs; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf08.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724727766; a=rsa-sha256; cv=none; b=OgotQ+K5nF6a0AQUwv96oA1Grr3pAwPdnJuq0O1UL9iDsudnh/AZKqjaKyuCrYt4g0RlQ+ FQ81YvRX1DTeDTH/pzyTz5M/zWdpi/k3bAOjhu/bPp9AZORIy+wObe0xiLjuXGo0m8oyrP H2UGxovKVybIYmwEw3UCyEfAYpGQ/fQ= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eClTrHDs; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf08.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724727766; 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=HC/dQAuJJc9P7JXnxr7YCyjlubaNoSxPwxLkgGLKaBw=; b=lEQ12mY8xn29rODBrqBfclUm+gmEOUDA2iI5vwCQfIJjT+xCqOIbOZh6PtK+HEQhMZNDyW cLqnux5997onzPCWOmjUr0ZKPjSh87ZNAXvrPdwzgpvjGaZ9FFARanWhorx2p7V+BRanrt hSADL9pG2O8Tkn7H3qkzbJ9Wkt6kPB0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 781FBA414CC; Tue, 27 Aug 2024 03:03:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FBE4C8B7A6; Tue, 27 Aug 2024 03:03:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724727829; bh=27cqGwuOVW8eGx/ZGwFvgMxuQ6m1KJSHIM8DINfBPro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eClTrHDsw5bze3VQM1izuo3k6Ruz46VEbDkR9eLTbtSzGk0Sn4iYhBaqh0F+D+rH1 OSMbS4v+PEaxr/ZZXlbFAnJy3XwPC4vOOS6GdmmZkCxU/ro8hLwdh2AY30ULWmqEyR xCd5s31I7vC16GUF4VGOFTMZQMNFzAc8mWZxxWuLOi73pRoQyb0lVQngW3BwDj9q0M 1qcrRQwpeUTK9JLwUvntkOFU5iL5pip0zw36zYm0YvvhMH72MzUYAp1sY/ZxDXVd7M InrrNfiZKRlVab5GMdTZqQU4lbJQjGqDznTvD5WNgHPJbKBLsEUbX9dWedDMFatali V1I0CsmY6EEtw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Brendan Higgins , David Gow , damon@lists.linux.dev, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org Subject: [PATCH 5/9] mm/damon/core-test: fix damon_test_ops_registration() for DAMON_VADDR unset case Date: Mon, 26 Aug 2024 20:03:32 -0700 Message-Id: <20240827030336.7930-6-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240827030336.7930-1-sj@kernel.org> References: <20240827030336.7930-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 07E3816001C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 1n71qc98ko4yuds7uyypy9ju1awnadg4 X-HE-Tag: 1724727829-149691 X-HE-Meta: U2FsdGVkX18Wn9a8t8sz9ktjLOqN2h1wnd0QnQM/HXOyTWSbPOnXCsVIh4OaCR6qSjscgifpJfnl12oSk1QPIZ280au7KJtmIYf4n+/R6Q1Ro+MEHjJCN5b9qyZjn/RTZFytmrLNDDFjn/KpoRpaaDbKDiIicKTE+gtMa0wzhIXb5jlbmi4JzplaJtNKzGwWG225MkHIo4CufeU6HB4II4kaRcPiZjpL0h8ZXaziX2I4615xiJa8/GEHZ8ieAvwvpn6LGTFgFWsm17oK3I4A/4EtT+KQ2V+2AD1rS0h07fEyI92VXSRK7l+tHQDxPSzz004WaiGSKHoF1KQ9HyCmi2yaoHfSKPWPPyVq7ichhvB7hjPNpYXJR+lUBSGTVowwYRe4zDHd61IJpt19CfutFlkhnNcLaesB7pjfEt6+WIFCIZA+A2Fz2QSWrV2c1D0X1QtyiawTEMKRSkrLkGGAv54SAIE9HIIO10HCs5dGc2EIcPMDVdmnoNHsvGk6DocK05sok8OaYhqZgnkEoi6UA4APQOw3ZJuGBfKf4niMxQ4fZHU/mMSQipoEuLA4r9HY3M4cCJr93QMx9NInyi0xgv0KWlfvMu4nCbrmNI6aIHYQi0/eFpQ/45a/pOe9WBD0CFSulgW5n7m46zfoC8kKbVM2OiYqDT5zpbz9MvE+JGCDnLQDYleyOQF/snibXhIXU4YHseO7uFs4JRHD2za+08MihFPfQXcLhofYH9JZ1+xv3hlWmIiQV4pNd9I7SMey7NqcMThcIFgpknAWS39BLdWR5OMKXVKlWbNQsAF5VufHjfDWoBtyw0z9NM9GgQfaVciDQ4O21NeUm24NEf2loWK2CevGyU1UXK5zLtSw1VhjjRHQoRnjbaEin3exZbDcrzR5IitCMz+FAvx/zsLr2HetyaKup6YeRB7i3xdEywIz3KQAkt4bwL+lOszJoKq5vTFYwWsq1RshJh/HVDS Mu77YAKJ J1EdiissHJd3T8d61wRlrcFVW/mr0ff2iOLVE90n+mzkRJ2ulg/moDS9o+xysdfKenUUgd/FXLUOavB0dMxzhfiUm8lgw5COKfrHpovTWPk3kU4h8n/foAOZvoHjVHu2Eu87GWZc7koR+MBJIbGkEZyXKgxdLVm12HTddQ23mYIcDfhlbucWeNKpFZopU3ERdYChjU1YfxU6S+xFQpd2jBAbQ+s/y87zDAm7YZdIf9RFYu2nFCusqkxFRgBq8VPnCYrASYl9t+BA8nfo1LVj/bvajowaSNjBEGWeL 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: List-Subscribe: List-Unsubscribe: DAMON core kunit test can be executed without CONFIG_DAMON_VADDR. In the case, vaddr DAMON ops is not registered. Meanwhile, ops registration kunit test assumes the vaddr ops is registered. Check and handle the case by registrering fake vaddr ops inside the test code. Fixes: 4f540f5ab4f2 ("mm/damon/core-test: add a kunit test case for ops registration") Signed-off-by: SeongJae Park --- mm/damon/core-test.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/mm/damon/core-test.h b/mm/damon/core-test.h index ef36d586d6ee..ae03df71737e 100644 --- a/mm/damon/core-test.h +++ b/mm/damon/core-test.h @@ -247,8 +247,16 @@ static void damon_test_ops_registration(struct kunit *test) { struct damon_ctx *c = damon_new_ctx(); struct damon_operations ops = {.id = DAMON_OPS_VADDR}, bak; + bool need_cleanup = false; - /* DAMON_OPS_VADDR is registered on subsys_initcall */ + /* DAMON_OPS_VADDR is registered only if CONFIG_DAMON_VADDR is set */ + if (!damon_is_registered_ops(DAMON_OPS_VADDR)) { + bak.id = DAMON_OPS_VADDR; + KUNIT_EXPECT_EQ(test, damon_register_ops(&bak), 0); + need_cleanup = true; + } + + /* DAMON_OPS_VADDR is ensured to be registered */ KUNIT_EXPECT_EQ(test, damon_select_ops(c, DAMON_OPS_VADDR), 0); /* Double-registration is prohibited */ @@ -274,6 +282,13 @@ static void damon_test_ops_registration(struct kunit *test) KUNIT_EXPECT_EQ(test, damon_register_ops(&ops), -EINVAL); damon_destroy_ctx(c); + + if (need_cleanup) { + mutex_lock(&damon_ops_lock); + damon_registered_ops[DAMON_OPS_VADDR] = + (struct damon_operations){}; + mutex_unlock(&damon_ops_lock); + } } static void damon_test_set_regions(struct kunit *test)