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: 10909 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1132442wru; Tue, 25 Oct 2022 10:38:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Rlx1395fKdVl+zFErCa3Etjpc/cgFaqaQkODbhqrnPakj4gZK2Izn6O75bYIHjeZZveRz X-Received: by 2002:a17:90b:4c0d:b0:20d:43db:cc14 with SMTP id na13-20020a17090b4c0d00b0020d43dbcc14mr46434591pjb.119.1666719529484; Tue, 25 Oct 2022 10:38:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666719529; cv=none; d=google.com; s=arc-20160816; b=hUmeQ3tK7dQK1Kz3YAAxtWOlCx6+lkAb7JLZig7nqTQg3WNUUF8SJYjRsdwgh4pgk/ 2j5vlinS8f6pT2OYhZK0EWj+PvcX3Vn3uERy1B0izEv/AH+89jjHMhVI6wjRwGY2PL6J 77O0ATuaFCJYW+lE286AK92qDaxMeluS7fxhjszxNB8EMiUpYtfbUMoYS0LgualqriYd vrnFDZsaR3XtlQe5Tn9+RHtV8tqWqpeO9S5+hGC9IMVH7rMobUtjcm5Svs8T2d7ed/tz au7e+2UGPlAl//YHtkZJdxec5XfAFezS4dVEmuHNgSWMmRWabQKjw1dQOUb/XacqCUAy mvZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=moRksDtfjES9Xxm+Vwb591fHii3lcZv05YN65M1agTQ=; b=tvXiMieYjConrIaYQeoVT0W1Qhyih0ZJ/dFOTII0nWO5zyt2gz48xuGJGH/YAjkBva XvxuXUn2QBkwbyBfrNWcaXIrCaDNMOGIT1otnzhHjGo5ZRDTdxaXcFWe+vS9tAwqERXi FoSmunvTWy1Up3l//j1iQBMlSyVrakUI2mn2JeFZxcLMZFbfzhpG0H7E4+HeOmurS3j/ WMxbiitE6gjOw3E1XxrY1QBSaD/IKJZBBYVJb6riDQrkvWI6wGPG5hSh4Rwj6RhhfTsi iUT+98u+kxrUFqHMZ17t/l7qTLX+NHMnQPA1nP6gUCtHKzfee0YEUt7BC5slzWPS/iSP EemA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=D13bipI5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pg16-20020a17090b1e1000b0020dbd4207fasi16637038pjb.46.2022.10.25.10.38.26; Tue, 25 Oct 2022 10:38:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=D13bipI5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231903AbiJYRhM (ORCPT + 99 others); Tue, 25 Oct 2022 13:37:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231429AbiJYRg7 (ORCPT ); Tue, 25 Oct 2022 13:36:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34EC3D64; Tue, 25 Oct 2022 10:36:59 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id D9D7BB81E5A; 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 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747682097755036762?= X-GMAIL-MSGID: =?utf-8?q?1747682097755036762?= 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