From patchwork Mon Jan 6 19:19:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13927777 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 B8FECE77188 for ; Mon, 6 Jan 2025 19:20:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E9E956B009A; Mon, 6 Jan 2025 14:19:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E4C166B009B; Mon, 6 Jan 2025 14:19:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CECC16B009C; Mon, 6 Jan 2025 14:19:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A973B6B009A for ; Mon, 6 Jan 2025 14:19:58 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 665DF1201E0 for ; Mon, 6 Jan 2025 19:19:58 +0000 (UTC) X-FDA: 82977992076.06.B957D41 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf02.hostedemail.com (Postfix) with ESMTP id C10F580002 for ; Mon, 6 Jan 2025 19:19:56 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fZi6ja1g; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf02.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736191196; a=rsa-sha256; cv=none; b=OoSi3GU3J5W/9oYPlSFJ9NmDgFTrbWe9KjpYLO2SaznJJ7sg7674LW8DnIpFPioU1TECqS 7MNT/gQZ4USq6te75oT4bbU+DErBr7D9XaZ9GxBubpzLqtFGgoCa//RFmTxPf0xK6E/SM2 DRVczWTZaRFMMhrnIqDY35yrgIrYd7I= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fZi6ja1g; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf02.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 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=1736191196; 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=pgUr5w7PHXmnIcfFMMd7kSnXq0DErC7wtWQ0arR4oa0=; b=4C7C7Kcz4ThSn3DoXeU9XkW6f0u2kTSVNpHzQ1ww3u1KGHiLfCde5zAUPI2goAacdnx8H+ uJVV3idxHrF8gXNlrw40Y9OnjHdqsmIt920/6n2Fu72yJgzraaSbco7bMF62y7JhqvnPTT 729x198opjq0KzMd/TYKy7uBCOD5WBE= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 54D255C5560; Mon, 6 Jan 2025 19:19:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D62CDC4CEE3; Mon, 6 Jan 2025 19:19:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736191196; bh=6FG97a2QCkNzbJZKIVGLLC/WiWRcYRT8nrNZYRnHJGo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fZi6ja1gh5bl6YSgAxZK1hxInVqn+ok+XIzlM8TEcTkEot1heugxkG76I+gSh03mS +1e/i1067m/RYwFznvyWJiRGAz8xBmWSElabpOJ1gVAs69BJuzAaH+fmm1/4M35K6E DcUQcwPjLZsJ+vmUQrU+dg2JrQdM769G8pT/cHBBC7RDNZXBLCGfu9QaBXPiAhHmbd rKtWlcPqoAXRRkw+cTxL3NzRb1mk905YxIIoj2+X5V7kvHDXTBc8hA20l7x8/YFHqA um6J6CPr+y3bS784cT0efu3RaYxpdf7JHQNfvPrwcaHTScppSWYodpiXh87zHbHogj p7H9i1Wo8U3QQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Brendan Higgins , David Gow , damon@lists.linux.dev, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 7/8] mm/damon: remove DAMON debugfs interface kunit tests Date: Mon, 6 Jan 2025 11:19:40 -0800 Message-Id: <20250106191941.107070-8-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250106191941.107070-1-sj@kernel.org> References: <20250106191941.107070-1-sj@kernel.org> MIME-Version: 1.0 X-Stat-Signature: 5od7fpimuf3mjpdw3t16x6peu7wfrdcz X-Rspam-User: X-Rspamd-Queue-Id: C10F580002 X-Rspamd-Server: rspam08 X-HE-Tag: 1736191196-414778 X-HE-Meta: U2FsdGVkX1+OKn1HVLk+90ar/59BGTcPQfc9dReOhaInvR73AFK0jhffUaWxEeCCdDVQZ7UqhhSj0QPMzgEQqYmrKta/QDU5lFh+DJ5L99BaWsj7Q7A5HjQwsA2KzKa4WnFJDyOHTPMouViblIF4MO7NG96RCxCFcErhNDRlWJKqMBBljg0ACe5iRykdBW/q5qdOS5ylc8QXqUqbaSKiJtA22DLzZ4ngr6cxNKvaYoqWidhj7IFcU6ONBKtpFa5O3qEQPVuthIdxynJck0zLX9QxjWKmD14nLiLbMCv5zY077xzGTZv/J/eCDE9eSrsy/WrtyBjw653M7ZtivDpVXUxCAcatWY7XW27ImKnuSLEb0PN8vt0R823972ge5WpKUex82KfxdnuyEuWBHUK66NY9FX1fNK8G05xugyTv6KLdQSGjjf7WYXdpHDrO/TLjEIAqCzIRtH4zQqJHD3wFkfjQeiVDTvAcELTwo+q636Oy8IkQkKK6njeEEYl8IeW7KowFoscmEU8vBcrjrJ2L2n/3ldNhiEgcSMz93BD4okySo5WjO5Ryhvdri86bnnnV+YV/+k18tZRHG2t/+HuLO5vo5GhxwU2nKgSl4t1RCiomSsPAdDc5B63hgRIyN/6i313tT2bjrQRtBwuPnu3YgvDrAyts9yKW+gLGEvkWvMeLR2IODCB03zaHDvEUtuA0n+G/3c7BIBrQ9X076S4lwwsIZ8UnG0cj/gDi8VQtKuo9ltJQuaGTWZN3dmmO7OJGncG9OErIEECppHnGyf8S1JsRyEnMGXPOPybEbLAhBH8pG1sIpzhOhgDcIWADQtYukO2ky02xmKPhsiGLxvLubnHohkzW8EfPJa3J/bXQCTzfu4a3Enwsp+/SJ567uvjuyqqy+hZirDIb6+tQdliXnlq4TVDczdJwPfMAcVMW3gGEzY7dy8pgCfMOHdbseO3nVmznp/04fa6lXr+Pubz kY0CbC53 rx919yKPfMnkH7hTQ8nuOsSXrgOQvjdDbH/EVZkxoE+hzUotnxh86RMNEiY10cBoDMYEaxNWd6+40HwwkPCW+aLM8FXaUG9djJXurlIaiHRlK6tLyPj6OyiiLtqkRCIssa846M97s58LZZ8OPOffnHS1QpFHTvaD0qsDxrug4McrOtVCVpkav7nGpMh4uazTUFxFT5o82Hwxew0jIa71xBF8MUhIGKIU0WqMTKKMpqSb0yUc= 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: It's time to remove DAMON debugfs interface, which has deprecated long before in February 2023. Read the cover letter of this patch series for more details. Remove kunit tests for the interface, to prevent unnecessary test failures. Signed-off-by: SeongJae Park --- mm/damon/Kconfig | 12 --- mm/damon/dbgfs.c | 2 - mm/damon/tests/.kunitconfig | 7 -- mm/damon/tests/dbgfs-kunit.h | 173 ----------------------------------- 4 files changed, 194 deletions(-) delete mode 100644 mm/damon/tests/dbgfs-kunit.h diff --git a/mm/damon/Kconfig b/mm/damon/Kconfig index d0357f3e9372..db0d92624e8b 100644 --- a/mm/damon/Kconfig +++ b/mm/damon/Kconfig @@ -89,18 +89,6 @@ config DAMON_DBGFS default y depends on DAMON_DBGFS_DEPRECATED -config DAMON_DBGFS_KUNIT_TEST - bool "Test for damon debugfs interface" if !KUNIT_ALL_TESTS - depends on DAMON_DBGFS && KUNIT=y - default KUNIT_ALL_TESTS - help - This builds the DAMON debugfs interface Kunit test suite. - - For more information on KUnit and unit tests in general, please refer - to the KUnit documentation. - - If unsure, say N. - config DAMON_RECLAIM bool "Build DAMON-based reclaim (DAMON_RECLAIM)" depends on DAMON_PADDR diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c index b4213bc47e44..5664c2cb0a5e 100644 --- a/mm/damon/dbgfs.c +++ b/mm/damon/dbgfs.c @@ -1144,5 +1144,3 @@ static int __init damon_dbgfs_init(void) } module_init(damon_dbgfs_init); - -#include "tests/dbgfs-kunit.h" diff --git a/mm/damon/tests/.kunitconfig b/mm/damon/tests/.kunitconfig index a73be044fc9b..36a450f57b58 100644 --- a/mm/damon/tests/.kunitconfig +++ b/mm/damon/tests/.kunitconfig @@ -13,10 +13,3 @@ CONFIG_DAMON_VADDR_KUNIT_TEST=y CONFIG_SYSFS=y CONFIG_DAMON_SYSFS=y CONFIG_DAMON_SYSFS_KUNIT_TEST=y - -# for DAMON debugfs interface -CONFIG_DEBUG_FS=y -CONFIG_DAMON_PADDR=y -CONFIG_DAMON_DBGFS_DEPRECATED=y -CONFIG_DAMON_DBGFS=y -CONFIG_DAMON_DBGFS_KUNIT_TEST=y diff --git a/mm/damon/tests/dbgfs-kunit.h b/mm/damon/tests/dbgfs-kunit.h deleted file mode 100644 index 087e53f641a8..000000000000 --- a/mm/damon/tests/dbgfs-kunit.h +++ /dev/null @@ -1,173 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * DAMON Debugfs Interface Unit Tests - * - * Author: SeongJae Park - */ - -#ifdef CONFIG_DAMON_DBGFS_KUNIT_TEST - -#ifndef _DAMON_DBGFS_TEST_H -#define _DAMON_DBGFS_TEST_H - -#include - -static void damon_dbgfs_test_str_to_ints(struct kunit *test) -{ - char *question; - int *answers; - int expected[] = {12, 35, 46}; - ssize_t nr_integers = 0, i; - - question = "123"; - answers = str_to_ints(question, strlen(question), &nr_integers); - KUNIT_EXPECT_EQ(test, (ssize_t)1, nr_integers); - KUNIT_EXPECT_EQ(test, 123, answers[0]); - kfree(answers); - - question = "123abc"; - answers = str_to_ints(question, strlen(question), &nr_integers); - KUNIT_EXPECT_EQ(test, (ssize_t)1, nr_integers); - KUNIT_EXPECT_EQ(test, 123, answers[0]); - kfree(answers); - - question = "a123"; - answers = str_to_ints(question, strlen(question), &nr_integers); - KUNIT_EXPECT_EQ(test, (ssize_t)0, nr_integers); - kfree(answers); - - question = "12 35"; - answers = str_to_ints(question, strlen(question), &nr_integers); - KUNIT_EXPECT_EQ(test, (ssize_t)2, nr_integers); - for (i = 0; i < nr_integers; i++) - KUNIT_EXPECT_EQ(test, expected[i], answers[i]); - kfree(answers); - - question = "12 35 46"; - answers = str_to_ints(question, strlen(question), &nr_integers); - KUNIT_EXPECT_EQ(test, (ssize_t)3, nr_integers); - for (i = 0; i < nr_integers; i++) - KUNIT_EXPECT_EQ(test, expected[i], answers[i]); - kfree(answers); - - question = "12 35 abc 46"; - answers = str_to_ints(question, strlen(question), &nr_integers); - KUNIT_EXPECT_EQ(test, (ssize_t)2, nr_integers); - for (i = 0; i < 2; i++) - KUNIT_EXPECT_EQ(test, expected[i], answers[i]); - kfree(answers); - - question = ""; - answers = str_to_ints(question, strlen(question), &nr_integers); - KUNIT_EXPECT_EQ(test, (ssize_t)0, nr_integers); - kfree(answers); - - question = "\n"; - answers = str_to_ints(question, strlen(question), &nr_integers); - KUNIT_EXPECT_EQ(test, (ssize_t)0, nr_integers); - kfree(answers); -} - -static void damon_dbgfs_test_set_targets(struct kunit *test) -{ - struct damon_ctx *ctx = dbgfs_new_ctx(); - char buf[64]; - - if (!damon_is_registered_ops(DAMON_OPS_PADDR)) { - dbgfs_destroy_ctx(ctx); - kunit_skip(test, "PADDR not registered"); - } - - /* Make DAMON consider target has no pid */ - damon_select_ops(ctx, DAMON_OPS_PADDR); - - dbgfs_set_targets(ctx, 0, NULL); - sprint_target_ids(ctx, buf, 64); - KUNIT_EXPECT_STREQ(test, (char *)buf, "\n"); - - dbgfs_set_targets(ctx, 1, NULL); - sprint_target_ids(ctx, buf, 64); - KUNIT_EXPECT_STREQ(test, (char *)buf, "42\n"); - - dbgfs_set_targets(ctx, 0, NULL); - sprint_target_ids(ctx, buf, 64); - KUNIT_EXPECT_STREQ(test, (char *)buf, "\n"); - - dbgfs_destroy_ctx(ctx); -} - -static void damon_dbgfs_test_set_init_regions(struct kunit *test) -{ - struct damon_ctx *ctx = damon_new_ctx(); - /* Each line represents one region in `` `` */ - char * const valid_inputs[] = {"1 10 20\n 1 20 30\n1 35 45", - "1 10 20\n", - "1 10 20\n0 39 59\n0 70 134\n 1 20 25\n", - ""}; - /* Reading the file again will show sorted, clean output */ - char * const valid_expects[] = {"1 10 20\n1 20 30\n1 35 45\n", - "1 10 20\n", - "0 39 59\n0 70 134\n1 10 20\n1 20 25\n", - ""}; - char * const invalid_inputs[] = {"3 10 20\n", /* target not exists */ - "1 10 20\n 1 14 26\n", /* regions overlap */ - "0 10 20\n1 30 40\n 0 5 8"}; /* not sorted by address */ - char *input, *expect; - int i, rc; - char buf[256]; - - if (!damon_is_registered_ops(DAMON_OPS_PADDR)) { - damon_destroy_ctx(ctx); - kunit_skip(test, "PADDR not registered"); - } - - damon_select_ops(ctx, DAMON_OPS_PADDR); - - dbgfs_set_targets(ctx, 3, NULL); - - /* Put valid inputs and check the results */ - for (i = 0; i < ARRAY_SIZE(valid_inputs); i++) { - input = valid_inputs[i]; - expect = valid_expects[i]; - - rc = set_init_regions(ctx, input, strnlen(input, 256)); - KUNIT_EXPECT_EQ(test, rc, 0); - - memset(buf, 0, 256); - sprint_init_regions(ctx, buf, 256); - - KUNIT_EXPECT_STREQ(test, (char *)buf, expect); - } - /* Put invalid inputs and check the return error code */ - for (i = 0; i < ARRAY_SIZE(invalid_inputs); i++) { - input = invalid_inputs[i]; - pr_info("input: %s\n", input); - rc = set_init_regions(ctx, input, strnlen(input, 256)); - KUNIT_EXPECT_EQ(test, rc, -EINVAL); - - memset(buf, 0, 256); - sprint_init_regions(ctx, buf, 256); - - KUNIT_EXPECT_STREQ(test, (char *)buf, ""); - } - - dbgfs_set_targets(ctx, 0, NULL); - damon_destroy_ctx(ctx); -} - -static struct kunit_case damon_test_cases[] = { - KUNIT_CASE(damon_dbgfs_test_str_to_ints), - KUNIT_CASE(damon_dbgfs_test_set_targets), - KUNIT_CASE(damon_dbgfs_test_set_init_regions), - {}, -}; - -static struct kunit_suite damon_test_suite = { - .name = "damon-dbgfs", - .test_cases = damon_test_cases, -}; -kunit_test_suite(damon_test_suite); - -#endif /* _DAMON_DBGFS_TEST_H */ - -#endif /* CONFIG_DAMON_KUNIT_TEST */