From patchwork Tue Oct 25 17:36:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13019606 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 40948FA3740 for ; Tue, 25 Oct 2022 17:37:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 35AED8E0002; Tue, 25 Oct 2022 13:37:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E44B8E0006; Tue, 25 Oct 2022 13:37:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 09A728E0002; Tue, 25 Oct 2022 13:36:59 -0400 (EDT) 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 DB1B08E0006 for ; Tue, 25 Oct 2022 13:36:59 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9B25F14041B for ; Tue, 25 Oct 2022 17:36:59 +0000 (UTC) X-FDA: 80060177358.14.47D716D Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf29.hostedemail.com (Postfix) with ESMTP id 29261120048 for ; Tue, 25 Oct 2022 17:36:57 +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 2B84561A91; Tue, 25 Oct 2022 17:36:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 046A2C43141; Tue, 25 Oct 2022 17:36:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666719416; bh=4NBEQVWjkZzG2RZ0IZhDEcaAZKCJsWQ5ei6FDrh1eE4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D13bipI5+ZFOlmA3P+OZjs7yvhTB1CxtPiSEjR/7eMpoGmFaJlnmC1ahl0M6VzJ2b jzRwMLGRPLeeuI1mE/u6kGnFuKsmODPXEkwnOJ2p3h7moHkT+/Is837OF5KYofdczS N7NQXo1Sipv9kc4PzBgnOGGPh1ce/xZFIxI83TXJj3DSyT8+z0pkWXOHGdDXNpA7J6 jyYdXgaYBRg6mtgKKzq22VwxIA76VBnvpnAJEO/j2ps/61WVED1Su5fagGUzlO/mZd PvCuTm5s7xP/RTRQPcjCc3+h/+7qY1/4fvqSrOpkUUHcyfFSN3HTT8MO/qpgHGY6tP SQ+BW/725/C5Q== From: SeongJae Park To: Andrew Morton Cc: Shuah Khan , linux-kernel@vger.kernel.org, damon@lists.linux.dev, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, SeongJae Park Subject: [PATCH 2/4] selftests/damon: add tests for DAMON_RECLAIM's enabled parameter Date: Tue, 25 Oct 2022 17:36:48 +0000 Message-Id: <20221025173650.90624-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221025173650.90624-1-sj@kernel.org> References: <20221025173650.90624-1-sj@kernel.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666719418; 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=moRksDtfjES9Xxm+Vwb591fHii3lcZv05YN65M1agTQ=; b=KwudST08Qs1+GXhmvMKxbL13w4dTB8KjDMY8iFssyjW8NV2Zf3Kai3PmjzojSswgGfOxcg FEW03xZ7M3+4Du6rR/LfvqzN9h1R2fpYj9BWUX1D8Gd2vXeFdXD6bKskR5bnXSsLhBxjrJ LJA+MpU/PQweGVdjpO4S0gmJbLyFLLE= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=D13bipI5; spf=pass (imf29.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666719418; a=rsa-sha256; cv=none; b=mBpRVd/V/tX0ulw9M7je+2yO2Upq3EcKcdjvaqhT5ITlGm2sNCu5oJ5ksGJWl3r6wBVdbj 4amFZtOOloOkGQ+aspdcijU2W6aemu5kHYmhrwxYS3RhgzxAtRLEVT0m9g2CAGNLEhRrLS /uC/+3ZLpXW+JYL6B9xHvIqo3pG1FfM= Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=D13bipI5; spf=pass (imf29.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-Stat-Signature: 1d6rm7ndnhyhj8ihimwwh5kg5xmmou8g X-Rspamd-Queue-Id: 29261120048 X-Rspamd-Server: rspam07 X-Rspam-User: X-HE-Tag: 1666719417-460535 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: Adds simple test cases for DAMON_RECLAIM's 'enabled' parameter. Those tests are focusing on the synchronous behavior of DAMON_RECLAIM enabling and disabling. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/Makefile | 1 + tools/testing/selftests/damon/reclaim.sh | 42 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100755 tools/testing/selftests/damon/reclaim.sh diff --git a/tools/testing/selftests/damon/Makefile b/tools/testing/selftests/damon/Makefile index a1fa2eff8192..dbbf18cb3e6b 100644 --- a/tools/testing/selftests/damon/Makefile +++ b/tools/testing/selftests/damon/Makefile @@ -8,5 +8,6 @@ TEST_PROGS = debugfs_attrs.sh debugfs_schemes.sh debugfs_target_ids.sh TEST_PROGS += debugfs_empty_targets.sh debugfs_huge_count_read_write.sh TEST_PROGS += debugfs_duplicate_context_creation.sh TEST_PROGS += sysfs.sh +TEST_PROGS += reclaim.sh include ../lib.mk diff --git a/tools/testing/selftests/damon/reclaim.sh b/tools/testing/selftests/damon/reclaim.sh new file mode 100755 index 000000000000..78dbc2334cbe --- /dev/null +++ b/tools/testing/selftests/damon/reclaim.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + +if [ $EUID -ne 0 ] +then + echo "Run as root" + exit $ksft_skip +fi + +damon_reclaim_enabled="/sys/module/damon_reclaim/parameters/enabled" +if [ ! -f "$damon_reclaim_enabled" ] +then + echo "No 'enabled' file. Maybe DAMON_RECLAIM not built" + exit $ksft_skip +fi + +nr_kdamonds=$(pgrep kdamond | wc -l) +if [ "$nr_kdamonds" -ne 0 ] +then + echo "Another kdamond is running" + exit $ksft_skip +fi + +echo Y > "$damon_reclaim_enabled" + +nr_kdamonds=$(pgrep kdamond | wc -l) +if [ "$nr_kdamonds" -ne 1 ] +then + echo "kdamond is not turned on" + exit 1 +fi + +echo N > "$damon_reclaim_enabled" +nr_kdamonds=$(pgrep kdamond | wc -l) +if [ "$nr_kdamonds" -ne 0 ] +then + echo "kdamond is not turned off" + exit 1 +fi