From patchwork Wed Jan 1 21:35:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13924280 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 6EF39E7718B for ; Wed, 1 Jan 2025 21:35:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A26226B0093; Wed, 1 Jan 2025 16:35:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9852C6B0095; Wed, 1 Jan 2025 16:35:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 826E46B0096; Wed, 1 Jan 2025 16:35:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 5EFA66B0093 for ; Wed, 1 Jan 2025 16:35:45 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 2499FA08FB for ; Wed, 1 Jan 2025 21:35:45 +0000 (UTC) X-FDA: 82960189788.29.407A08A Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf16.hostedemail.com (Postfix) with ESMTP id 14A03180007 for ; Wed, 1 Jan 2025 21:34:52 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PfmiU+x5; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf16.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=1735767321; 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=3M97cbYxPslVly5BGoYn7ODaJYJ15xt7l1+7pwjQd3wtS7IW91fBlXz3QUJXHgkF5Je75Z jgpZWu3mSSvl3bChxQLjd9RLBHLGBCdM+xNOSAdUizpWyKMOjKE/SkjMevuN2FWLD8TyC2 JuQWMewBvkq70S/n15gHggNxpleccVo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735767321; a=rsa-sha256; cv=none; b=bskCEoDWINVBsHj1RiYR6772wpbIhv/ZI8HLyRVLqq4zuxZHTNH6omxok8q49t9HrumuYx z+NVrRm72xXs6CG98/slxreePTj7E3fAg9vIzxUwh1aax7f+1bWN4p9RHh+hIXKfaYJ/u4 hBbtR5NtE+InqFKbSNtDGhrTDi1Mmts= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PfmiU+x5; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf16.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4B2D65C5FB2; Wed, 1 Jan 2025 21:35:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1AAC8C4CECE; Wed, 1 Jan 2025 21:35:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735767342; bh=6FG97a2QCkNzbJZKIVGLLC/WiWRcYRT8nrNZYRnHJGo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PfmiU+x53jG0P2hkwOLeJFVcJzHVBEXfJOtZ7ZHtL0QGphXvJ7hChiXdUtQEI6gKh iGHSSkCjlQ2XYrrQbxhovBS80RTyAWV1U2mwMN7jUs6Ikl8J/rMMPyKNF3BQzdT6t6 7jrNIYWMHc0ENW3QRCzVLdg5JZg5nA7QPhk4StNU91ZfJeV04T+0iiEFzw4t2ShShc FgddVLy7XaT+djzpLJIxK8dOMWjy5Hou6jJmxndNwgsnPLx0NObN7cgal64/nYEQtU uMknyqLl8NuP3oLbd+X33NiUodQ09gmDPVe9daQQHgVO3EIh4f3q1FHM0zmWMq5Dqk NvgNaj2KwnTIg== 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 6/7] mm/damon: remove DAMON debugfs interface kunit tests Date: Wed, 1 Jan 2025 13:35:26 -0800 Message-Id: <20250101213527.74203-7-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250101213527.74203-1-sj@kernel.org> References: <20250101213527.74203-1-sj@kernel.org> MIME-Version: 1.0 X-Stat-Signature: zz8s1zr64qttcxybrjo5mwkr55ybtamh X-Rspamd-Queue-Id: 14A03180007 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1735767292-525246 X-HE-Meta: U2FsdGVkX183oMNVW8gRvKo8kyoEEkVUfG2ysny5XKYXGwPLu38S19SY3VETEfe0WfXVOm+cntuQfdWG/hsCrfUir7G3YIL2lkKubT8seqML5c+UG3QjXw+eU6dEFLyK/v5zC0oEBhc/v+qBYRjUKgIgYQl6VGsyfIzVVygrdolcF4MBrcTlLI3pf2BMeY9yEa5KLw5bnRQZ6UKxtcbiMmRpacbGebYEVS11DGVC0jwmzPl2lwHm/QXUqNSBf8gLOEzJ8UhVXBjBpN4d8ZAiQMrmviQwKyqNPnp5znxyyT+a+/rEkHYMDuYSn9t2uvQY7bWh1aZb5zwQ/BmpqvhrrlIh2L1kevBtL5XD0ioc+jEO74NO6K38HzpaA6/Dmx0lnz3neJHBBGpjX5kRU5YXQDywfNUDLXcEGnrKyesVQ6jzO9C9NVHmawdj+D5RTl5zrD7qLtVKh3Qg11uRWBbBdUm5NTsu4l2raNes2DsKfziUqTb5cPFc5L6IZR7YVE6CfYyYMVa2iiyRd0FyoGuX2daQ8gRiQYt6LZ2WrM9pNtRO5nmOpanUnLTGkthfetGbAteRpvtqACpu4YMwQUsgH+3EnualMlArfGUdBNCeuXnkMQUVUwCc0aA/Ld9Zo8EGL5byZk4vRavNficiQPOXU2cQLS6AQaMpgnEbcS40n/xyMOwFIABniYx0na/iQ352T5EWX0vT+tE1A9j+uxJnKaxQQ56XWlpeQpzLSBwxasIpifPUrjheCW8Q4UJ0F9rOQTR7vZ6rLnkWQLdSboMPzc1u28sO/21SgebcIo8anm55/KOp71k0gffEltEWiYjqp9IlzrcBP63Fr2xvmqqcDLjV7XkIF4hQRZeb6cevocMY1zACLYJUrNQA4kLco+njF3pSAZ2IOW9piYd0hetbxbPfEwEafyUuSqzYQvJvVl3gdAx/80+6q+R9+k0ALtw/okpQ0WUQQXJ/9rze4Jf GEribyys 3w/abi+VROMAdb6Jv2YmP6zPYGoj/zfeT55tuZfRiMRJXVUZUzr4ogxX01v+riQAN+P4ZjAI24Qei5XXrjHgzABmD5z+2LPv70zympNcPxi6xmUp/HHR5SG7KtyzlInecWF29h+51u5x7PzGifYanCbcHV0ulLGa9DTaDQASZ+vAWD/PfpX0Q+yVoSQe54uGL0NZcaMkkIlF89I6RTcdqOPWBCLr2Ym/Ww9uJEjtxnY7Jvgo= 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 */