From patchwork Tue Oct 15 17:54:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13836806 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 DD32CD1D88F for ; Tue, 15 Oct 2024 17:54:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C59C6B0096; Tue, 15 Oct 2024 13:54:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 24B4A6B0098; Tue, 15 Oct 2024 13:54:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0781F6B0099; Tue, 15 Oct 2024 13:54:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D59206B0096 for ; Tue, 15 Oct 2024 13:54:31 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 6376C1A17CE for ; Tue, 15 Oct 2024 17:54:15 +0000 (UTC) X-FDA: 82676586090.06.44025B4 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf25.hostedemail.com (Postfix) with ESMTP id ADBB4A000A for ; Tue, 15 Oct 2024 17:54:24 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=O4lzcSy6; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf25.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=1729014764; a=rsa-sha256; cv=none; b=C0OwCZgFNtG2VG3EqAFJ9gMAa1VzlOUFsPudyzRkY95CWg2mH3ekKCdLNxYQEsbRYfuFrf F7Md4+fisEkqcy7dv0ZeQ2deakK1YKmFf2PPSBecM4YG8SUpAIpM4kJKcsyyX+tZZphk+8 EYKCuFek7RoZd7xiOaZmAbtlG2cDYag= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=O4lzcSy6; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf25.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=1729014764; 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=YbQj1LfW8wIMlDtW04KsmgNArcZ6QLpc8f+8GRDflTo=; b=K3oc3Fkk0S5uuofRcM0djoxV+tY+Ucg64Nar6hQVL0q1L4cKKwi4p49YLYPodSdMHG2b8s o89z0GnQXtp+AJOxvaaV9R/PV8Y9ESFfKyZIdKqSreov6osoMBMgWDKtmmrdHxetQFjTap JL2AwPtDTCYH20kLPEU235TTYw8E45M= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id EDC5DA42608; Tue, 15 Oct 2024 17:54:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35735C4CED5; Tue, 15 Oct 2024 17:54:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729014868; bh=+5y1um4gitXtylrMffYca0ktxuX6uSb/9QDvMPQdSFU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O4lzcSy6i79Wom+pv+6s2P2i6bYMcG7Nytm2ZVcIpvbvyj4OzDLielOBUIofnAKNF U7OWoBscoDYa5BrM03l8S593Wc8K+kuK8b5LjpVqNaFq9Dt2CvvQjeazjbhNdPTJ+P e/HoNuKk6YdF6WmHd+YdwGC5BfPk0Opt7HVeq9cakKqLRgx+tY6I1URfS63q73dBIz dDDHU7s6PovCqRo5CK/9wY8VHtWNJiVhGQA3u1/VZW0s31VUMZJY+W1Usz5xBW9Hn2 bW4FAmQ5Vrd7LPLEOyCplGqU4aNnVCG97BRUJE+vfUQNLY6+Krt5viH/WZn6w3nU4+ GnLLUsIxV676Q== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , Brendan Higgins , David Gow , damon@lists.linux.dev, linux-mm@kvack.org, kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 6/7] mm/damon: remove DAMON debugfs interface kunit tests Date: Tue, 15 Oct 2024 10:54:11 -0700 Message-Id: <20241015175412.60563-7-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241015175412.60563-1-sj@kernel.org> References: <20241015175412.60563-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: ADBB4A000A X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: n3zoa8ogkf7t18smsaiupr9rj8e6m7g4 X-HE-Tag: 1729014864-265706 X-HE-Meta: U2FsdGVkX19h1Bf3T22X5aFj+J1oog4cQhOEPEwh4W1kUvNbdpLEXOVUypXF0OrKoKyl6xiOc/bocCzod7QslAEyI6MIfeyqz4CDfnN1v23SPJv7TazEGu7yyWKYlcbrk18G8vv+SaRN0nrs2Bf0tvPKcaXwHqyr9vL5va3+y7vTybNLfKD/Ps3pdh1RTFJkykQ85XFH3gUpuZ97mMW5Sq/mvJ8J5AKZvJr8JEXzNTIYroUvV/WkLfmvU1luZiLKTWZF/W/REh5nyXmsQr7+5PCesQMfRTgiQO96zusihxVohtKd/eN2RjK+c/RJhBX4dO68cVg4Xai2wDRi0G7m3J/+k/Ven3yLoUihoCWFdZ5WFnk7dNVFTabkiKTsQVNGPaRbnVT3Yk2KLeL9OK/ZdprbZsfG1CNZrafw4bl0m4EhNQ0MQkZY1VBRXiMw7bqqWQcoj/pa8NdTfcsSIAHST4HSpQzH8nfs6Mhs8Uv8EuyWrf6gTS7X7A6UG0/zWoVKmawT/nYHUojMl5KlUeVxuw77mBxo8Na8Bn4NCDkz3P1UatS05Y37+JXslRjZNShnp8WpUIQsKkEGQnoeQYjTnTqipV+7Hq+4iTWh+9TMLgfYEUd8B2T46EsK3WnEo4h0LxcXI0gGz0qd0ptvAGuglbVcQfhuiyTRXIoFcrKYrEv/urJn/vGBAeIOa71WEH8dBJnObKOF6URzKNmZ1jFaFrHjTH05FYUxbn1LxKzTaoCk855fizpgoxYwGc0wqIzfasbuMHFZQfziBq+OzJetJ8ald9/8dG3iit66DqlItUqvJheMJBdyGciQNkZADP0E41Vmfrmw/4ujpN5Y7pA/I1gB3gsHrngCTdEdMHVDHBtW3/AvsV4oOy0FKcX5p1A8EZ4v1SwDwrenfBZnH6x/BNZPVjc7WvY8VphZ70l5sIftAb+sAQzLsSyB2b/OxHL2beNbcNXtsXguZ/GMy6W QH4UU/DC 0xxNEDBG/t0tOkyDB8jOgANmJE7g+JVXIIdcaa1g3BKvn0xZmHqs0MyZCMvPcvjdFChZaEUjtlOsHgaH5MibValCtefHw0iLzG5QG1V2x1NaF3Ar1jZFiDVXiWaEaVhcoY4kZNVZRcWHZm7QNwasVR8fc+ygJWKP4sh+2AlWY5p/U3VwCegQhhto/LZqAxyMYtgObYot/080ykEouATzdu0xjJvsNUXwg3naxrocegB0S9T4= 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 35b72f88983a..5ee5e62c0a1e 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 d2ecfcc8db86..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_TEST_H */ - -#endif /* CONFIG_DAMON_KUNIT_TEST */