From patchwork Wed Dec 1 15:04:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12650159 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 B1DA3C433F5 for ; Wed, 1 Dec 2021 15:11:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4DEAD6B0089; Wed, 1 Dec 2021 10:08:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 46A516B008A; Wed, 1 Dec 2021 10:08:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2BA1E6B008C; Wed, 1 Dec 2021 10:08:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0148.hostedemail.com [216.40.44.148]) by kanga.kvack.org (Postfix) with ESMTP id 16CDF6B0089 for ; Wed, 1 Dec 2021 10:08:35 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id C87BE1812E208 for ; Wed, 1 Dec 2021 15:08:24 +0000 (UTC) X-FDA: 78869556528.07.8FCDCE8 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf13.hostedemail.com (Postfix) with ESMTP id 751C6105B603 for ; Wed, 1 Dec 2021 15:05:04 +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 ams.source.kernel.org (Postfix) with ESMTPS id 0C694B81F6E; Wed, 1 Dec 2021 15:05:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41BC5C53FCC; Wed, 1 Dec 2021 15:04:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638371099; bh=LnVq1MEm2bCsu9Z8LA3AWGyf0J5QJ1npa9erK6XACwM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fKE1umMNcZcEJrZUq9xVufn4g8c2edh5yFbyvY6b4Wf8XDc0tMQP3s4H832Sk+k1j k1gt7arlHYl1vnDooDiRmdiB9y3E3zPE+9ZnmwmFr2OBksR15oA43V2sCaB0Hfr1Js 4LVeGCcAcTpTg0hqXVC1SYg+cClPnZ4AEt1FK9EEkVy2tshf9TAiejafEuFm3AZZYp 8Yo78c1orW2M2zl39yXwGG9e1mHS94RJtouxGGCq3ACk3K0ozczPMDjFsTHYyKtjaO rWd3DTtmaVARqtl2vbUwoOknnXoANg2BPmd7o+oGeZZqLODhzpZRgCM9hU3DHbu5RT dCcyfoS+w6++g== From: SeongJae Park To: akpm@linux-foundation.org Cc: shuah@kernel.org, brendanhiggins@google.com, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 01/11] mm/damon/core: Use better timer mechanisms selection threshold Date: Wed, 1 Dec 2021 15:04:30 +0000 Message-Id: <20211201150440.1088-2-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211201150440.1088-1-sj@kernel.org> References: <20211201150440.1088-1-sj@kernel.org> X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 751C6105B603 X-Stat-Signature: atzmqyjeza4yidz16aueuhs7w4kuna54 Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fKE1umMN; spf=pass (imf13.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-HE-Tag: 1638371104-802272 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: DAMON is using hrtimer if requested sleep time is <=100ms, while the suggested threshold[1] is <=20ms. This commit applies the threshold. [1] Documentation/timers/timers-howto.rst Fixes: ee801b7dd7822 ("mm/damon/schemes: activate schemes based on a watermarks mechanism") Signed-off-by: SeongJae Park --- mm/damon/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index 8cd8fddc931e..ccc62479549a 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -978,7 +978,8 @@ static unsigned long damos_wmark_wait_us(struct damos *scheme) static void kdamond_usleep(unsigned long usecs) { - if (usecs > 100 * 1000) + /* See Documentation/timers/timers-howto.rst for the thresholds */ + if (usecs > 20 * USEC_PER_MSEC) schedule_timeout_idle(usecs_to_jiffies(usecs)); else usleep_idle_range(usecs, usecs + 1); From patchwork Wed Dec 1 15:04:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12650155 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 57DA0C433FE for ; Wed, 1 Dec 2021 15:10:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ECC026B0083; Wed, 1 Dec 2021 10:07:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E53E46B0085; Wed, 1 Dec 2021 10:07:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD08D6B0087; Wed, 1 Dec 2021 10:07:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0158.hostedemail.com [216.40.44.158]) by kanga.kvack.org (Postfix) with ESMTP id B20CD6B0083 for ; Wed, 1 Dec 2021 10:07:38 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 7786A180B3060 for ; Wed, 1 Dec 2021 15:07:28 +0000 (UTC) X-FDA: 78869554176.13.C929CB8 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf22.hostedemail.com (Postfix) with ESMTP id BC382C9F6 for ; Wed, 1 Dec 2021 15:05:05 +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 sin.source.kernel.org (Postfix) with ESMTPS id D7906CE1F97; Wed, 1 Dec 2021 15:05:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0692FC53FD4; Wed, 1 Dec 2021 15:04:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638371100; bh=QvKLyeU28c3oSLP1SZ6xf8Zv4RAz+uvm7dyfC1S1NOE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S6ZOyrMtRVXJ0gxKymQSSiPsPFARFklHLvVFd25Rqhxlm6z2yj2yoHMMMDdW+NsIt /Yn5z3lzZ9gQ0rGZPrGNh1G8a0qmIN6BP4lbOfcYFgzr1boPuQJBakCtGTtef9iJrw gsZDWFNNxzbDfYQeV7edP04a2bchhDxfIBlOMqmYgKsqT1bE5GN7ciRTVJeVj8cocN XqqGW28xR+JnvwZSW7AULLw9Cdq76p7Ka/MfrxLweY5O49ubJGKxCPh6ll0V3droj7 l40DkKMCXSbmUysDNRgVDYWUhoWnp8pgPFT9RR8pK0HmPHgMds2vHmHoyfaIY3U/hD IEs6giIGZpB2g== From: SeongJae Park To: akpm@linux-foundation.org Cc: shuah@kernel.org, brendanhiggins@google.com, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 02/11] mm/damon/dbgfs: Remove an unnecessary error message Date: Wed, 1 Dec 2021 15:04:31 +0000 Message-Id: <20211201150440.1088-3-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211201150440.1088-1-sj@kernel.org> References: <20211201150440.1088-1-sj@kernel.org> X-Stat-Signature: u45pa7zwus411u4o7g6phq8q4pzxfnux Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=S6ZOyrMt; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf22.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: BC382C9F6 X-HE-Tag: 1638371105-444721 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: When wrong scheme action is requested via the debugfs interface, DAMON prints an error message. Because the function returns error code, this is not really needed. Because the code path is triggered by the user specified input, this can result in kernel log mistakenly being messy. To avoid the case, this commit removes the message. Fixes: af122dd8f3c0 ("mm/damon/dbgfs: support DAMON-based Operation Schemes") Signed-off-by: SeongJae Park --- mm/damon/dbgfs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c index 4bf4204444ab..5b628990ae6e 100644 --- a/mm/damon/dbgfs.c +++ b/mm/damon/dbgfs.c @@ -210,10 +210,8 @@ static struct damos **str_to_schemes(const char *str, ssize_t len, &wmarks.low, &parsed); if (ret != 18) break; - if (!damos_action_valid(action)) { - pr_err("wrong action %d\n", action); + if (!damos_action_valid(action)) goto fail; - } if (min_sz > max_sz || min_nr_a > max_nr_a || min_age > max_age) goto fail; From patchwork Wed Dec 1 15:04:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12650149 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 D6862C433F5 for ; Wed, 1 Dec 2021 15:09:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9507F6B0080; Wed, 1 Dec 2021 10:07:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D60A6B0081; Wed, 1 Dec 2021 10:07:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 79E026B0082; Wed, 1 Dec 2021 10:07:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0102.hostedemail.com [216.40.44.102]) by kanga.kvack.org (Postfix) with ESMTP id 64F496B0080 for ; Wed, 1 Dec 2021 10:07:16 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 2CED28249980 for ; Wed, 1 Dec 2021 15:07:06 +0000 (UTC) X-FDA: 78869553252.27.DD1A710 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf20.hostedemail.com (Postfix) with ESMTP id 79A50D000C98 for ; Wed, 1 Dec 2021 15:05:06 +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 ams.source.kernel.org (Postfix) with ESMTPS id AECA8B81DE4; Wed, 1 Dec 2021 15:05:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4256C56748; Wed, 1 Dec 2021 15:05:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638371101; bh=sQWMtyONHmc3W+Sgg4QUiiH5In2nUhULeFdo0mShTis=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KuLTSc5tK1l9ku/4X3hIvrCsTFR605bwQnRHywxxvsKhtGsDKcvlVLeZ7h1knqpU6 8Nhz9aLb/+kVTo3gsf+4VFFoLg92ZbukwubUK7KzeRUY1EMtkB/dMoeeU35+Pbxkuf XTFRW/rvAGHTQZnYwDgk0nDKlq5k5FUfuBESQBX0G3jf7GRUgOoHOHtRmf23av+jFA QEmcYoKlbqy5T6trsm4ct6oNtZ6rpLCkL8blYDltnW6Bhg+ibHCX8HLnaMyPoBMhwh tZ06D2moRfmYxvo1CykV4UpTin2lNzjCq3n2zhbEP29Q35J7tdrv3Xzebet3//b1vR oVrgNFatqUNVQ== From: SeongJae Park To: akpm@linux-foundation.org Cc: shuah@kernel.org, brendanhiggins@google.com, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 03/11] mm/damon/core: Remove unnecessary error messages Date: Wed, 1 Dec 2021 15:04:32 +0000 Message-Id: <20211201150440.1088-4-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211201150440.1088-1-sj@kernel.org> References: <20211201150440.1088-1-sj@kernel.org> X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 79A50D000C98 X-Stat-Signature: a6r67zkterwuhw7e4jzt3599wgpfyfb7 Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KuLTSc5t; spf=pass (imf20.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-HE-Tag: 1638371106-126173 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: DAMON core prints error messages when damon_target object creation is failed or wrong monitoring attributes are given. Because appropriate error code is returned for each case, the messages are not essential. Also, because the code path can be triggered with user-specified input, this could result in kernel log mistakenly being messy. To avoid the case, this commit removes the messages. Fixes: 4bc05954d007 ("mm/damon: implement a debugfs-based user space interface") Fixes: b9a6ac4e4ede ("mm/damon: adaptively adjust regions") Signed-off-by: SeongJae Park --- mm/damon/core.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index ccc62479549a..04b8df7fd9e9 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -282,7 +282,6 @@ int damon_set_targets(struct damon_ctx *ctx, for (i = 0; i < nr_ids; i++) { t = damon_new_target(ids[i]); if (!t) { - pr_err("Failed to alloc damon_target\n"); /* The caller should do cleanup of the ids itself */ damon_for_each_target_safe(t, next, ctx) damon_destroy_target(t); @@ -312,16 +311,10 @@ int damon_set_attrs(struct damon_ctx *ctx, unsigned long sample_int, unsigned long aggr_int, unsigned long primitive_upd_int, unsigned long min_nr_reg, unsigned long max_nr_reg) { - if (min_nr_reg < 3) { - pr_err("min_nr_regions (%lu) must be at least 3\n", - min_nr_reg); + if (min_nr_reg < 3) return -EINVAL; - } - if (min_nr_reg > max_nr_reg) { - pr_err("invalid nr_regions. min (%lu) > max (%lu)\n", - min_nr_reg, max_nr_reg); + if (min_nr_reg > max_nr_reg) return -EINVAL; - } ctx->sample_interval = sample_int; ctx->aggr_interval = aggr_int; From patchwork Wed Dec 1 15:04:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12650145 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 88911C433EF for ; Wed, 1 Dec 2021 15:07:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 57E2A6B007B; Wed, 1 Dec 2021 10:07:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 505226B007D; Wed, 1 Dec 2021 10:07:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A73C6B007E; Wed, 1 Dec 2021 10:07:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0092.hostedemail.com [216.40.44.92]) by kanga.kvack.org (Postfix) with ESMTP id 214B36B007B for ; Wed, 1 Dec 2021 10:07:01 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id DE73A180A72EA for ; Wed, 1 Dec 2021 15:06:50 +0000 (UTC) X-FDA: 78869552580.07.8C94CFC Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf12.hostedemail.com (Postfix) with ESMTP id A8EB910067E7 for ; Wed, 1 Dec 2021 15:05:06 +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 sin.source.kernel.org (Postfix) with ESMTPS id 066D6CE1DBB; Wed, 1 Dec 2021 15:05:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9BECC53FAD; Wed, 1 Dec 2021 15:05:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638371102; bh=LqY9Ctk3Sg1j0lXQYGLS8aivIzz7RYVNYXV8X4hWops=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TQ8dSjxVpueR792RFEpdNWiVG5R/cIx0PcmHyRlWOGB0I4u0YZFttL/8+My0kEM+G qGAbDDHXPEtttgiEDA1JELn6nFQtNch76XcOx7MYIyvl++cQbcmCCnyZNJmiswhcvw JYNrjtxgPubnRvfq+ghSfgV2t9VZXdBdIpvZHiQZCEoBbZiNztVoOvfTC92FuLPdl4 sxgLTxXD++8TgF1r3/h5vhO2BuAkwX0tGoNaQDJ3h6HEyk4IQCYqNdHbM1WlaOl2B0 MxQyX0m4UKuQ9pOd7gvrbIcscfq9PGHTpz0z7IOIzIuU5jde0M6587X0qHv6Kz1Cza dBdnS3eY3Wb6A== From: SeongJae Park To: akpm@linux-foundation.org Cc: shuah@kernel.org, brendanhiggins@google.com, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 04/11] mm/damon/vaddr: Remove an unnecessary warning message Date: Wed, 1 Dec 2021 15:04:33 +0000 Message-Id: <20211201150440.1088-5-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211201150440.1088-1-sj@kernel.org> References: <20211201150440.1088-1-sj@kernel.org> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: A8EB910067E7 X-Stat-Signature: wg4xhb13m47qjxf8xifacmjzric4ochq Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=TQ8dSjxV; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org X-HE-Tag: 1638371106-936440 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: The DAMON virtual address space monitoring primitive prints a warning message for wrong DAMOS action. However, it is not essential as the code returns appropriate failure in the case. This commit removes the message to make the log clean. Fixes: 6dea8add4d28 ("mm/damon/vaddr: support DAMON-based Operation Schemes") Signed-off-by: SeongJae Park Reviewed-by: Muchun Song --- mm/damon/vaddr.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c index 79481f0c2838..a65b1a4d236c 100644 --- a/mm/damon/vaddr.c +++ b/mm/damon/vaddr.c @@ -617,7 +617,6 @@ static int damon_va_apply_scheme(struct damon_ctx *ctx, struct damon_target *t, case DAMOS_STAT: return 0; default: - pr_warn("Wrong action %d\n", scheme->action); return -EINVAL; } From patchwork Wed Dec 1 15:04:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12650151 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 C86EFC433F5 for ; Wed, 1 Dec 2021 15:09:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 249E36B0081; Wed, 1 Dec 2021 10:07:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1D2146B0082; Wed, 1 Dec 2021 10:07:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0239C6B0083; Wed, 1 Dec 2021 10:07:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0195.hostedemail.com [216.40.44.195]) by kanga.kvack.org (Postfix) with ESMTP id E2D986B0081 for ; Wed, 1 Dec 2021 10:07:19 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id A6D3D8A3D0 for ; Wed, 1 Dec 2021 15:07:09 +0000 (UTC) X-FDA: 78869553378.12.196F09E Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf17.hostedemail.com (Postfix) with ESMTP id D00F1F001E82 for ; Wed, 1 Dec 2021 15:05:04 +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 ams.source.kernel.org (Postfix) with ESMTPS id 5A679B81FDF; Wed, 1 Dec 2021 15:05:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70F61C53FCC; Wed, 1 Dec 2021 15:05:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638371103; bh=OBCz9UA299ZoQQWT5MORsqWesgyjbdJekOP8AmbpsCs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L+GGhLC5Zay1gDZ2+gowpThvm766UXmaVlJ/6pBF5VFD7vamoiW9u4zylwjMI4L/S xENgawHtYFqohqfObAzWevaW6O2NQcm6w7j7lNXBaL1mBw3Ab8j2anlfNVTfAfqZNQ dD4L9C9qKvz+QbgJFsB3Sn45xyHxNGN6EkGOOp85bL1oXcu4ftJ5DAzb0JaZMpP6cj ZKWozefYgMqpaNn3X3G9Oi2v4gEbKEsp2AOuCFmjUB35+v4QfbcS0G3n8k6r3TdWNw 7lMZkRwG9qwQdJeHl3mbUaHEOizPCaHg/HtM5mxK2ycK2iDoJ7Ii58rRaSnQaIX3U3 JcW0WctOQ1vLA== From: SeongJae Park To: akpm@linux-foundation.org Cc: shuah@kernel.org, brendanhiggins@google.com, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 05/11] mm/damon/vaddr-test: Split a test function having >1024 bytes frame size Date: Wed, 1 Dec 2021 15:04:34 +0000 Message-Id: <20211201150440.1088-6-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211201150440.1088-1-sj@kernel.org> References: <20211201150440.1088-1-sj@kernel.org> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: D00F1F001E82 X-Stat-Signature: 4cgotyhdipdot53ayh4n15kztbfebfme Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=L+GGhLC5; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf17.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org X-HE-Tag: 1638371104-640252 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: On some configuration[1], 'damon_test_split_evenly()' kunit test function has >1024 bytes frame size, so below build warning is triggered: CC mm/damon/vaddr.o In file included from mm/damon/vaddr.c:672: mm/damon/vaddr-test.h: In function 'damon_test_split_evenly': mm/damon/vaddr-test.h:309:1: warning: the frame size of 1064 bytes is larger than 1024 bytes [-Wframe-larger-than=] 309 | } | ^ This commit fixes the warning by separating the common logics in the function. [1] https://lore.kernel.org/linux-mm/202111182146.OV3C4uGr-lkp@intel.com/ Reported-by: kernel test robot Fixes: 17ccae8bb5c9 ("mm/damon: add kunit tests") Signed-off-by: SeongJae Park --- mm/damon/vaddr-test.h | 77 ++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/mm/damon/vaddr-test.h b/mm/damon/vaddr-test.h index ecfd0b2ed222..3097ef9c662a 100644 --- a/mm/damon/vaddr-test.h +++ b/mm/damon/vaddr-test.h @@ -252,59 +252,62 @@ static void damon_test_apply_three_regions4(struct kunit *test) new_three_regions, expected, ARRAY_SIZE(expected)); } -static void damon_test_split_evenly(struct kunit *test) +static void damon_test_split_evenly_fail(struct kunit *test, + unsigned long start, unsigned long end, unsigned int nr_pieces) { - struct damon_ctx *c = damon_new_ctx(); - struct damon_target *t; - struct damon_region *r; - unsigned long i; - - KUNIT_EXPECT_EQ(test, damon_va_evenly_split_region(NULL, NULL, 5), - -EINVAL); - - t = damon_new_target(42); - r = damon_new_region(0, 100); - KUNIT_EXPECT_EQ(test, damon_va_evenly_split_region(t, r, 0), -EINVAL); + struct damon_target *t = damon_new_target(42); + struct damon_region *r = damon_new_region(start, end); damon_add_region(r, t); - KUNIT_EXPECT_EQ(test, damon_va_evenly_split_region(t, r, 10), 0); - KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 10u); + KUNIT_EXPECT_EQ(test, + damon_va_evenly_split_region(t, r, nr_pieces), -EINVAL); + KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 1u); - i = 0; damon_for_each_region(r, t) { - KUNIT_EXPECT_EQ(test, r->ar.start, i++ * 10); - KUNIT_EXPECT_EQ(test, r->ar.end, i * 10); + KUNIT_EXPECT_EQ(test, r->ar.start, start); + KUNIT_EXPECT_EQ(test, r->ar.end, end); } + damon_free_target(t); +} + +static void damon_test_split_evenly_succ(struct kunit *test, + unsigned long start, unsigned long end, unsigned int nr_pieces) +{ + struct damon_target *t = damon_new_target(42); + struct damon_region *r = damon_new_region(start, end); + unsigned long expected_width = (end - start) / nr_pieces; + unsigned long i = 0; - t = damon_new_target(42); - r = damon_new_region(5, 59); damon_add_region(r, t); - KUNIT_EXPECT_EQ(test, damon_va_evenly_split_region(t, r, 5), 0); - KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 5u); + KUNIT_EXPECT_EQ(test, + damon_va_evenly_split_region(t, r, nr_pieces), 0); + KUNIT_EXPECT_EQ(test, damon_nr_regions(t), nr_pieces); - i = 0; damon_for_each_region(r, t) { - if (i == 4) + if (i == nr_pieces - 1) break; - KUNIT_EXPECT_EQ(test, r->ar.start, 5 + 10 * i++); - KUNIT_EXPECT_EQ(test, r->ar.end, 5 + 10 * i); + KUNIT_EXPECT_EQ(test, + r->ar.start, start + i++ * expected_width); + KUNIT_EXPECT_EQ(test, r->ar.end, start + i * expected_width); } - KUNIT_EXPECT_EQ(test, r->ar.start, 5 + 10 * i); - KUNIT_EXPECT_EQ(test, r->ar.end, 59ul); + KUNIT_EXPECT_EQ(test, r->ar.start, start + i * expected_width); + KUNIT_EXPECT_EQ(test, r->ar.end, end); damon_free_target(t); +} - t = damon_new_target(42); - r = damon_new_region(5, 6); - damon_add_region(r, t); - KUNIT_EXPECT_EQ(test, damon_va_evenly_split_region(t, r, 2), -EINVAL); - KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 1u); +static void damon_test_split_evenly(struct kunit *test) +{ + struct damon_ctx *c = damon_new_ctx(); + + KUNIT_EXPECT_EQ(test, damon_va_evenly_split_region(NULL, NULL, 5), + -EINVAL); + + damon_test_split_evenly_fail(test, 0, 100, 0); + damon_test_split_evenly_succ(test, 0, 100, 10); + damon_test_split_evenly_succ(test, 5, 59, 5); + damon_test_split_evenly_fail(test, 5, 6, 2); - damon_for_each_region(r, t) { - KUNIT_EXPECT_EQ(test, r->ar.start, 5ul); - KUNIT_EXPECT_EQ(test, r->ar.end, 6ul); - } - damon_free_target(t); damon_destroy_ctx(c); } From patchwork Wed Dec 1 15:04:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12650141 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 B7C5AC433F5 for ; Wed, 1 Dec 2021 15:06:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 30DC46B0074; Wed, 1 Dec 2021 10:06:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2947C6B0075; Wed, 1 Dec 2021 10:06:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 074226B007B; Wed, 1 Dec 2021 10:06:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0035.hostedemail.com [216.40.44.35]) by kanga.kvack.org (Postfix) with ESMTP id E8C646B0074 for ; Wed, 1 Dec 2021 10:06:46 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id ABF5084775 for ; Wed, 1 Dec 2021 15:06:36 +0000 (UTC) X-FDA: 78869551992.03.6D56D82 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf16.hostedemail.com (Postfix) with ESMTP id 63206F003748 for ; Wed, 1 Dec 2021 15:05:05 +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 ams.source.kernel.org (Postfix) with ESMTPS id 20F7DB82015; Wed, 1 Dec 2021 15:05:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 481D1C53FD2; Wed, 1 Dec 2021 15:05:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638371103; bh=nMvEMx9k5IK3wjDZ51A43sizsqcw2go8DgM5XkopF88=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r2MAP9GBrsmaOi7c2RYIkFbH+11PGH2NYi1oLnww8zPh8lxqLXLBtnpw7AQD6Bct1 f5kCYVluvB8MBzBLaEVXLsGcYU1xxi0Y16tnbH9BTSvGqrvbwtQmanJtfWOMDDaqY9 +Q+EaV5NiGMNigvk3qEUszmS/iGf6WND0TU3AEFGWs6R4ZWWIMdwWND6awQBwEuNAH 3QfQabM/AEoJ4UIpgqpPzBCbIWk07/VtxnQbQIykHlRKjht9KcDkAj2fgeTdGo9cW2 hfvxcIVcYLvTc0j/Ok2T3Ev1JMc43qwMFdxjjfjOSFDc+BDncaLkfqKB9HzFfAtyZh QureMzo946rYw== From: SeongJae Park To: akpm@linux-foundation.org Cc: shuah@kernel.org, brendanhiggins@google.com, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 06/11] mm/damon/vaddr-test: Remove unnecessary variables Date: Wed, 1 Dec 2021 15:04:35 +0000 Message-Id: <20211201150440.1088-7-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211201150440.1088-1-sj@kernel.org> References: <20211201150440.1088-1-sj@kernel.org> X-Stat-Signature: g8fr6sxmb1fqjrrxmfwah3ups1tksnsi Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=r2MAP9GB; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf16.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 63206F003748 X-HE-Tag: 1638371105-568125 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: A couple of test functions in DAMON virtual address space monitoring primitives implementation has unnecessary damon_ctx variables. This commit removes those. Signed-off-by: SeongJae Park --- mm/damon/vaddr-test.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/mm/damon/vaddr-test.h b/mm/damon/vaddr-test.h index 3097ef9c662a..6a1b9272ea12 100644 --- a/mm/damon/vaddr-test.h +++ b/mm/damon/vaddr-test.h @@ -135,7 +135,6 @@ static void damon_do_test_apply_three_regions(struct kunit *test, struct damon_addr_range *three_regions, unsigned long *expected, int nr_expected) { - struct damon_ctx *ctx = damon_new_ctx(); struct damon_target *t; struct damon_region *r; int i; @@ -145,7 +144,6 @@ static void damon_do_test_apply_three_regions(struct kunit *test, r = damon_new_region(regions[i * 2], regions[i * 2 + 1]); damon_add_region(r, t); } - damon_add_target(ctx, t); damon_va_apply_three_regions(t, three_regions); @@ -154,8 +152,6 @@ static void damon_do_test_apply_three_regions(struct kunit *test, KUNIT_EXPECT_EQ(test, r->ar.start, expected[i * 2]); KUNIT_EXPECT_EQ(test, r->ar.end, expected[i * 2 + 1]); } - - damon_destroy_ctx(ctx); } /* @@ -298,8 +294,6 @@ static void damon_test_split_evenly_succ(struct kunit *test, static void damon_test_split_evenly(struct kunit *test) { - struct damon_ctx *c = damon_new_ctx(); - KUNIT_EXPECT_EQ(test, damon_va_evenly_split_region(NULL, NULL, 5), -EINVAL); @@ -307,8 +301,6 @@ static void damon_test_split_evenly(struct kunit *test) damon_test_split_evenly_succ(test, 0, 100, 10); damon_test_split_evenly_succ(test, 5, 59, 5); damon_test_split_evenly_fail(test, 5, 6, 2); - - damon_destroy_ctx(c); } static struct kunit_case damon_test_cases[] = { From patchwork Wed Dec 1 15:04:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12650153 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 8A02EC433F5 for ; Wed, 1 Dec 2021 15:10:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F4E76B0082; Wed, 1 Dec 2021 10:07:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 57A646B0083; Wed, 1 Dec 2021 10:07:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41C226B0085; Wed, 1 Dec 2021 10:07:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0073.hostedemail.com [216.40.44.73]) by kanga.kvack.org (Postfix) with ESMTP id 2A96F6B0082 for ; Wed, 1 Dec 2021 10:07:28 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id DBBCE8249980 for ; Wed, 1 Dec 2021 15:07:17 +0000 (UTC) X-FDA: 78869553714.06.B446AE0 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf26.hostedemail.com (Postfix) with ESMTP id E5B7120275F0 for ; Wed, 1 Dec 2021 15:05:05 +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 ams.source.kernel.org (Postfix) with ESMTPS id 1024EB8200F; Wed, 1 Dec 2021 15:05:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D460C53FCC; Wed, 1 Dec 2021 15:05:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638371104; bh=YjXMqJsAM3rfUd7mH+zkWhp7VeCDe+o7nOiWHutAaY8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RiNuqg7NkzJI7j6wUZfGzHMLxdJiRLVTfD6TuCgWXcYT+Yhz2ZmTchyuPuVwBIn0L ymL7lMQhBx93dJPVyzKOkO2rwIstfeXp3MFozilY1Ukex5IlXRoO05OLJKAXtFvSQ4 o+4FuxIiq3BZHsrk5q/LsC3qEFUIoI5p3ahoJ5PXGk2lRu/517QNSoSlPbTWcCXmym MG4FWogp/dJCpTzjymUs6ky/a0VJv/zPqJMb/8zogRzcB4UAkVvbSo98CcdSA5eXjo e2p/SqHr9xaHmEVOv1njjrlMj2dayI5XH/1aIpVytl5CgWHAhLgoR1NFkcUPRnBBO6 Zkq6/fj+AN7fg== From: SeongJae Park To: akpm@linux-foundation.org Cc: shuah@kernel.org, brendanhiggins@google.com, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 07/11] selftests/damon: Skip test if DAMON is running Date: Wed, 1 Dec 2021 15:04:36 +0000 Message-Id: <20211201150440.1088-8-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211201150440.1088-1-sj@kernel.org> References: <20211201150440.1088-1-sj@kernel.org> X-Stat-Signature: gka8cbnmte83r1damg11c7opbqwfduw8 X-Rspamd-Queue-Id: E5B7120275F0 X-Rspamd-Server: rspam07 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RiNuqg7N; spf=pass (imf26.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-HE-Tag: 1638371105-429716 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: Testing the DAMON debugfs files while DAMON is running makes no sense, as any write to the debugfs files will fails. This commit makes the test be skipped in the case. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/debugfs_attrs.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/testing/selftests/damon/debugfs_attrs.sh b/tools/testing/selftests/damon/debugfs_attrs.sh index 196b6640bf37..fc80380c59f0 100644 --- a/tools/testing/selftests/damon/debugfs_attrs.sh +++ b/tools/testing/selftests/damon/debugfs_attrs.sh @@ -44,6 +44,15 @@ test_content() { source ./_chk_dependency.sh +ksft_skip=4 + +damon_onoff="$DBGFS/monitor_on" +if [ $(cat "$damon_onoff") = "on" ] +then + echo "monitoring is on" + exit $ksft_skip +fi + # Test attrs file # =============== From patchwork Wed Dec 1 15:04:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12650157 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 3C7A6C433F5 for ; Wed, 1 Dec 2021 15:11:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 57BA06B0087; Wed, 1 Dec 2021 10:08:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 52B5A6B0088; Wed, 1 Dec 2021 10:08:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F2F56B0089; Wed, 1 Dec 2021 10:08:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0182.hostedemail.com [216.40.44.182]) by kanga.kvack.org (Postfix) with ESMTP id 2D57C6B0087 for ; Wed, 1 Dec 2021 10:08:17 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id DEE4218131217 for ; Wed, 1 Dec 2021 15:08:06 +0000 (UTC) X-FDA: 78869555772.18.BF3A7F9 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf10.hostedemail.com (Postfix) with ESMTP id D972F6009E14 for ; Wed, 1 Dec 2021 15:05:06 +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 ams.source.kernel.org (Postfix) with ESMTPS id 9E94DB82014; Wed, 1 Dec 2021 15:05:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5FACC58327; Wed, 1 Dec 2021 15:05:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638371105; bh=ZLNKsQlFSLqYMsBCfb792+tzS72UfrLFubOGm2kx3Lw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pj7KV7zpySualdRJt4DuoXFbR0fal4UOQ6kG2NVd9hSzWzHfLomHVhgfrvswswnsG t6ZfSC6Ak87/YTuQrFpJoYmdlLRc40NdTzACd42zzmsH4BEJqcTAFH7ITOf6ZKtUSS xEIVNeqpqWZe9zXDTNVihpVXQQsTXhUW+L5P8XKZQBp5b9Bc/rBeu0m09kY1mj9h/E Inp7g6vLvHSiD+wjLWnprxWV3jOgdBnAlb3C+p4k0tyBNhsSmNZKPvbOB29YcL1ZyP sne6CTWbmrBreJvXBWRcJ3Gxs3NSCR8SyI5BpJXEDJhm3uKkjlVfeIiiTzbQlAy6DS /39oY+HQ0BGCQ== From: SeongJae Park To: akpm@linux-foundation.org Cc: shuah@kernel.org, brendanhiggins@google.com, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 08/11] selftests/damon: Test DAMON enabling with empty target_ids case Date: Wed, 1 Dec 2021 15:04:37 +0000 Message-Id: <20211201150440.1088-9-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211201150440.1088-1-sj@kernel.org> References: <20211201150440.1088-1-sj@kernel.org> X-Stat-Signature: mzxxcohh1pe1sqpnjn3aewfs139qrftt X-Rspamd-Queue-Id: D972F6009E14 X-Rspamd-Server: rspam07 Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Pj7KV7zp; spf=pass (imf10.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-HE-Tag: 1638371106-696644 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: DAMON debugfs didn't check empty targets when starting monitoring, and the issue is fixed with commit b5ca3e83ddb0 ("mm/damon/dbgfs: add adaptive_targets list check before enable monitor_on"). To avoid future regression, this commit adds a test case for that in DAMON selftests. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/debugfs_attrs.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/testing/selftests/damon/debugfs_attrs.sh b/tools/testing/selftests/damon/debugfs_attrs.sh index fc80380c59f0..d0916373f310 100644 --- a/tools/testing/selftests/damon/debugfs_attrs.sh +++ b/tools/testing/selftests/damon/debugfs_attrs.sh @@ -94,4 +94,13 @@ test_write_succ "$file" "" "$orig_content" "empty input" test_content "$file" "$orig_content" "" "empty input written" echo "$orig_content" > "$file" +# Test empty targets case +# ======================= + +orig_target_ids=$(cat "$DBGFS/target_ids") +echo "" > "$DBGFS/target_ids" +orig_monitor_on=$(cat "$DBGFS/monitor_on") +test_write_fail "$DBGFS/monitor_on" "on" "orig_monitor_on" "empty target ids" +echo "$orig_target_ids" > "$DBGFS/target_ids" + echo "PASS" From patchwork Wed Dec 1 15:04:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12650147 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 8B998C433F5 for ; Wed, 1 Dec 2021 15:08:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CD1EA6B007D; Wed, 1 Dec 2021 10:07:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C58846B007E; Wed, 1 Dec 2021 10:07:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF9946B0080; Wed, 1 Dec 2021 10:07:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0029.hostedemail.com [216.40.44.29]) by kanga.kvack.org (Postfix) with ESMTP id 978D86B007D for ; Wed, 1 Dec 2021 10:07:01 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 6275A886C5 for ; Wed, 1 Dec 2021 15:06:51 +0000 (UTC) X-FDA: 78869552622.28.6EFC235 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf12.hostedemail.com (Postfix) with ESMTP id EDF811001C30 for ; Wed, 1 Dec 2021 15:05:07 +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 ams.source.kernel.org (Postfix) with ESMTPS id 626FFB81DF7; Wed, 1 Dec 2021 15:05:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8AAF0C53FCD; Wed, 1 Dec 2021 15:05:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638371106; bh=0vdcMyUQGuwcxJbQPs8RdnvesQ4Ampc8D6OYRBEjNxw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l9McXxE2OjcxknwERNHehKK7ECaWNllnE7932jLxeibsb31zhE65+Tl9aj+OXo+bv WPw3jvfYhvR9YFcE5dPmI773d7/FUihCflK2pBmVDyGXlksIqH0nuxUxMK2FPOf44W i35T0zWst3ZdBJh8sp18kjmPwt58qaw6pEBN/7+S80qNcS4ReKCM+rjQi6TRag08d7 /VR74cDuiM4JNkCaTGCrufgd3poEaboNw3bVNsBrhdJMYoIOVb7x//kwM+BbSQ/JAB z1nWF9xI6P4gYRNFHhTRAvYTxNFchr+2O9zyflzUltgwsRdIbQHqOCjoO+M1Acudnf WoOSX5zPF6olg== From: SeongJae Park To: akpm@linux-foundation.org Cc: shuah@kernel.org, brendanhiggins@google.com, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 09/11] selftests/damon: Test wrong DAMOS condition ranges input Date: Wed, 1 Dec 2021 15:04:38 +0000 Message-Id: <20211201150440.1088-10-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211201150440.1088-1-sj@kernel.org> References: <20211201150440.1088-1-sj@kernel.org> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: EDF811001C30 X-Stat-Signature: 7sdy1sr1i3m8du7dzb5ikdtxuur53zni Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=l9McXxE2; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org X-HE-Tag: 1638371107-576644 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: A patch titled "mm/damon/schemes: add the validity judgment of thresholds"[1] makes DAMON debugfs interface to validate DAMON scheme inputs. This commit adds a test case for the validation logic in DAMON selftests. [1] https://lore.kernel.org/linux-mm/d78360e52158d786fcbf20bc62c96785742e76d3.1637239568.git.xhao@linux.alibaba.com/ Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/debugfs_attrs.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/damon/debugfs_attrs.sh b/tools/testing/selftests/damon/debugfs_attrs.sh index d0916373f310..1ef118617167 100644 --- a/tools/testing/selftests/damon/debugfs_attrs.sh +++ b/tools/testing/selftests/damon/debugfs_attrs.sh @@ -77,6 +77,8 @@ test_write_succ "$file" "1 2 3 4 5 6 4 0 0 0 1 2 3 1 100 3 2 1" \ test_write_fail "$file" "1 2 3 4 5 6 3 0 0 0 1 2 3 1 100 3 2 1" "$orig_content" "multi lines" test_write_succ "$file" "" "$orig_content" "disabling" +test_write_fail "$file" "2 1 2 1 10 1 3 10 1 1 1 1 1 1 1 1 2 3" \ + "$orig_content" "wrong condition ranges" echo "$orig_content" > "$file" # Test target_ids file From patchwork Wed Dec 1 15:04:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12650139 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 87EA6C433EF for ; Wed, 1 Dec 2021 15:06:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0EAC36B0073; Wed, 1 Dec 2021 10:06:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 09A146B0074; Wed, 1 Dec 2021 10:06:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA4D36B0078; Wed, 1 Dec 2021 10:06:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0095.hostedemail.com [216.40.44.95]) by kanga.kvack.org (Postfix) with ESMTP id DCC096B0073 for ; Wed, 1 Dec 2021 10:06:04 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 9ACD282499B9 for ; Wed, 1 Dec 2021 15:05:54 +0000 (UTC) X-FDA: 78869550228.03.ACBA423 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf29.hostedemail.com (Postfix) with ESMTP id F286F9000A41 for ; Wed, 1 Dec 2021 15:05:07 +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 ams.source.kernel.org (Postfix) with ESMTPS id 29AD5B81FE1; Wed, 1 Dec 2021 15:05:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50104C53FD5; Wed, 1 Dec 2021 15:05:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638371106; bh=nP0zCJWJh2R15aZXtogVlD4kCvqivnJ+cG8oPlUtwQo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DjC450bSsbfSeu9uKxK/FCRKWkhs5OCSuvUeLurwI68vVCMqMUml6QrdDnWW2l3cX p5E6osJdfF+wwtKApr+slRKF2CkJR8t/VaG2RhykFjYv4xvw200Ri81bVi3jv8cDFt /v6yR6TC0utIJv0NQFrB4zSaMJ5dhFaHeLPydF1BThEsCaAITWFhlsY/2pCZg0rd3Y GltDaEHxBzhwzwtj5SywsLTzZ5wSf3q/m+yWWuZCLG7+87boyKajswY4FSVRhZCiEJ rQ/l3XWYLZBLxJltSf11SvedVw/r60iSHNmMG2Nx+gxfPM1sIiKO1L9DKDmpVSceFP hXjibou/gztRw== From: SeongJae Park To: akpm@linux-foundation.org Cc: shuah@kernel.org, brendanhiggins@google.com, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 10/11] selftests/damon: Test debugfs file reads/writes with huge count Date: Wed, 1 Dec 2021 15:04:39 +0000 Message-Id: <20211201150440.1088-11-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211201150440.1088-1-sj@kernel.org> References: <20211201150440.1088-1-sj@kernel.org> X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: F286F9000A41 X-Stat-Signature: wfsbweiiuyzi7gda8e91nm37zdz3pgf8 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DjC450bS; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf29.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org X-HE-Tag: 1638371107-17388 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: DAMON debugfs interface users were able to trigger warning by writing some files with arbitrarily large 'count' parameter. The issue is fixed with commit db7a347b26fe ("mm/damon/dbgfs: use '__GFP_NOWARN' for user-specified size buffer allocation"). This commit adds a test case for the issue in DAMON selftests to avoid future regressions. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/.gitignore | 2 + tools/testing/selftests/damon/Makefile | 2 + .../testing/selftests/damon/debugfs_attrs.sh | 18 +++++++++ .../selftests/damon/huge_count_read_write.c | 39 +++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 tools/testing/selftests/damon/.gitignore create mode 100644 tools/testing/selftests/damon/huge_count_read_write.c diff --git a/tools/testing/selftests/damon/.gitignore b/tools/testing/selftests/damon/.gitignore new file mode 100644 index 000000000000..c6c2965a6607 --- /dev/null +++ b/tools/testing/selftests/damon/.gitignore @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +huge_count_read_write diff --git a/tools/testing/selftests/damon/Makefile b/tools/testing/selftests/damon/Makefile index 8a3f2cd9fec0..f0aa954b5d13 100644 --- a/tools/testing/selftests/damon/Makefile +++ b/tools/testing/selftests/damon/Makefile @@ -1,6 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for damon selftests +TEST_GEN_FILES += huge_count_read_write + TEST_FILES = _chk_dependency.sh TEST_PROGS = debugfs_attrs.sh diff --git a/tools/testing/selftests/damon/debugfs_attrs.sh b/tools/testing/selftests/damon/debugfs_attrs.sh index 1ef118617167..23a7b48ca7d3 100644 --- a/tools/testing/selftests/damon/debugfs_attrs.sh +++ b/tools/testing/selftests/damon/debugfs_attrs.sh @@ -105,4 +105,22 @@ orig_monitor_on=$(cat "$DBGFS/monitor_on") test_write_fail "$DBGFS/monitor_on" "on" "orig_monitor_on" "empty target ids" echo "$orig_target_ids" > "$DBGFS/target_ids" +# Test huge count read write +# ========================== + +dmesg -C + +for file in "$DBGFS/"* +do + ./huge_count_read_write "$file" +done + +if dmesg | grep -q WARNING +then + dmesg + exit 1 +else + exit 0 +fi + echo "PASS" diff --git a/tools/testing/selftests/damon/huge_count_read_write.c b/tools/testing/selftests/damon/huge_count_read_write.c new file mode 100644 index 000000000000..ad7a6b4cf338 --- /dev/null +++ b/tools/testing/selftests/damon/huge_count_read_write.c @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Author: SeongJae Park + */ + +#include +#include +#include +#include + +void write_read_with_huge_count(char *file) +{ + int filedesc = open(file, O_RDWR); + char buf[25]; + int ret; + + printf("%s %s\n", __func__, file); + if (filedesc < 0) { + fprintf(stderr, "failed opening %s\n", file); + exit(1); + } + + write(filedesc, "", 0xfffffffful); + perror("after write: "); + ret = read(filedesc, buf, 0xfffffffful); + perror("after read: "); + close(filedesc); +} + +int main(int argc, char *argv[]) +{ + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + exit(1); + } + write_read_with_huge_count(argv[1]); + + return 0; +} From patchwork Wed Dec 1 15:04:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12650161 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 1FD12C433EF for ; Wed, 1 Dec 2021 15:12:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 26C486B009B; Wed, 1 Dec 2021 10:10:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 21BBB6B009C; Wed, 1 Dec 2021 10:10:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E4026B009D; Wed, 1 Dec 2021 10:10:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0122.hostedemail.com [216.40.44.122]) by kanga.kvack.org (Postfix) with ESMTP id F22806B009B for ; Wed, 1 Dec 2021 10:10:02 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id B88FE181AC9C6 for ; Wed, 1 Dec 2021 15:09:52 +0000 (UTC) X-FDA: 78869560224.23.1158DED Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf12.hostedemail.com (Postfix) with ESMTP id 9B31C10067FC for ; Wed, 1 Dec 2021 15:05:09 +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 ams.source.kernel.org (Postfix) with ESMTPS id F3126B81DE4; Wed, 1 Dec 2021 15:05:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1776BC53FD2; Wed, 1 Dec 2021 15:05:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638371107; bh=12Gg2gHRZzGJmTMNLn1vki+uItnZBSKL2VYrvKMNfGM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZTgr4ULb6pFVZFpgxoQEHrShkKMnZQGR46jEYJ9kb+BHip2uED09gDT/gdaVoAtZ1 hSOraBh03SCjQBb64aGanRGXBbKfoommXFDkwVThNIfpVWbUQxMiaGMm89launsYHq PxoNEdbqLWQS58HwgTON2691Q0bj68zt2E0x2PsdupxmkKrWlB0uNUjhzhxjjkVTV9 m/4btsLCFQYtiruLsCSuSy7pSXKz7jisUzZ99VEB+n9TRvMNAOH3So63ZAsEb1ubg6 JgO0biZL6HIT6jhisQA2SkOLVfRFgnuLi9LoXCNJxaIWkIegJPeLMgfdlS1tprB9m9 iGFXCjijHE0Xg== From: SeongJae Park To: akpm@linux-foundation.org Cc: shuah@kernel.org, brendanhiggins@google.com, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 11/11] selftests/damon: Split test cases Date: Wed, 1 Dec 2021 15:04:40 +0000 Message-Id: <20211201150440.1088-12-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211201150440.1088-1-sj@kernel.org> References: <20211201150440.1088-1-sj@kernel.org> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 9B31C10067FC X-Stat-Signature: 6m153x4h6ihocodx17xyf8bnjdox7xi1 Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZTgr4ULb; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org X-HE-Tag: 1638371109-401277 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000315, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Currently, the single test program, debugfs.sh, contains all test cases for DAMON. When one of the cases is failed, finding which case is failed from the test log is not so easy, and all remaining test will be skipped. To improve the situation, this commit splits the single program into small test programs having their own names. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/Makefile | 5 +- .../selftests/damon/_debugfs_common.sh | 52 ++++++++ .../testing/selftests/damon/debugfs_attrs.sh | 111 +----------------- .../selftests/damon/debugfs_empty_targets.sh | 13 ++ .../damon/debugfs_huge_count_read_write.sh | 22 ++++ .../selftests/damon/debugfs_schemes.sh | 19 +++ .../selftests/damon/debugfs_target_ids.sh | 19 +++ 7 files changed, 129 insertions(+), 112 deletions(-) create mode 100644 tools/testing/selftests/damon/_debugfs_common.sh create mode 100644 tools/testing/selftests/damon/debugfs_empty_targets.sh create mode 100644 tools/testing/selftests/damon/debugfs_huge_count_read_write.sh create mode 100644 tools/testing/selftests/damon/debugfs_schemes.sh create mode 100644 tools/testing/selftests/damon/debugfs_target_ids.sh diff --git a/tools/testing/selftests/damon/Makefile b/tools/testing/selftests/damon/Makefile index f0aa954b5d13..937d36ae9a69 100644 --- a/tools/testing/selftests/damon/Makefile +++ b/tools/testing/selftests/damon/Makefile @@ -3,7 +3,8 @@ TEST_GEN_FILES += huge_count_read_write -TEST_FILES = _chk_dependency.sh -TEST_PROGS = debugfs_attrs.sh +TEST_FILES = _chk_dependency.sh _debugfs_common.sh +TEST_PROGS = debugfs_attrs.sh debugfs_schemes.sh debugfs_target_ids.sh +TEST_PROGS += debugfs_empty_targets.sh debugfs_huge_count_read_write.sh include ../lib.mk diff --git a/tools/testing/selftests/damon/_debugfs_common.sh b/tools/testing/selftests/damon/_debugfs_common.sh new file mode 100644 index 000000000000..48989d4813ae --- /dev/null +++ b/tools/testing/selftests/damon/_debugfs_common.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +test_write_result() { + file=$1 + content=$2 + orig_content=$3 + expect_reason=$4 + expected=$5 + + echo "$content" > "$file" + if [ $? -ne "$expected" ] + then + echo "writing $content to $file doesn't return $expected" + echo "expected because: $expect_reason" + echo "$orig_content" > "$file" + exit 1 + fi +} + +test_write_succ() { + test_write_result "$1" "$2" "$3" "$4" 0 +} + +test_write_fail() { + test_write_result "$1" "$2" "$3" "$4" 1 +} + +test_content() { + file=$1 + orig_content=$2 + expected=$3 + expect_reason=$4 + + content=$(cat "$file") + if [ "$content" != "$expected" ] + then + echo "reading $file expected $expected but $content" + echo "expected because: $expect_reason" + echo "$orig_content" > "$file" + exit 1 + fi +} + +source ./_chk_dependency.sh + +damon_onoff="$DBGFS/monitor_on" +if [ $(cat "$damon_onoff") = "on" ] +then + echo "monitoring is on" + exit $ksft_skip +fi diff --git a/tools/testing/selftests/damon/debugfs_attrs.sh b/tools/testing/selftests/damon/debugfs_attrs.sh index 23a7b48ca7d3..902e312bca89 100644 --- a/tools/testing/selftests/damon/debugfs_attrs.sh +++ b/tools/testing/selftests/damon/debugfs_attrs.sh @@ -1,57 +1,7 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 -test_write_result() { - file=$1 - content=$2 - orig_content=$3 - expect_reason=$4 - expected=$5 - - echo "$content" > "$file" - if [ $? -ne "$expected" ] - then - echo "writing $content to $file doesn't return $expected" - echo "expected because: $expect_reason" - echo "$orig_content" > "$file" - exit 1 - fi -} - -test_write_succ() { - test_write_result "$1" "$2" "$3" "$4" 0 -} - -test_write_fail() { - test_write_result "$1" "$2" "$3" "$4" 1 -} - -test_content() { - file=$1 - orig_content=$2 - expected=$3 - expect_reason=$4 - - content=$(cat "$file") - if [ "$content" != "$expected" ] - then - echo "reading $file expected $expected but $content" - echo "expected because: $expect_reason" - echo "$orig_content" > "$file" - exit 1 - fi -} - -source ./_chk_dependency.sh - -ksft_skip=4 - -damon_onoff="$DBGFS/monitor_on" -if [ $(cat "$damon_onoff") = "on" ] -then - echo "monitoring is on" - exit $ksft_skip -fi +source _debugfs_common.sh # Test attrs file # =============== @@ -65,62 +15,3 @@ test_write_fail "$file" "1 2 3 5 4" "$orig_content" \ "min_nr_regions > max_nr_regions" test_content "$file" "$orig_content" "1 2 3 4 5" "successfully written" echo "$orig_content" > "$file" - -# Test schemes file -# ================= - -file="$DBGFS/schemes" -orig_content=$(cat "$file") - -test_write_succ "$file" "1 2 3 4 5 6 4 0 0 0 1 2 3 1 100 3 2 1" \ - "$orig_content" "valid input" -test_write_fail "$file" "1 2 -3 4 5 6 3 0 0 0 1 2 3 1 100 3 2 1" "$orig_content" "multi lines" -test_write_succ "$file" "" "$orig_content" "disabling" -test_write_fail "$file" "2 1 2 1 10 1 3 10 1 1 1 1 1 1 1 1 2 3" \ - "$orig_content" "wrong condition ranges" -echo "$orig_content" > "$file" - -# Test target_ids file -# ==================== - -file="$DBGFS/target_ids" -orig_content=$(cat "$file") - -test_write_succ "$file" "1 2 3 4" "$orig_content" "valid input" -test_write_succ "$file" "1 2 abc 4" "$orig_content" "still valid input" -test_content "$file" "$orig_content" "1 2" "non-integer was there" -test_write_succ "$file" "abc 2 3" "$orig_content" "the file allows wrong input" -test_content "$file" "$orig_content" "" "wrong input written" -test_write_succ "$file" "" "$orig_content" "empty input" -test_content "$file" "$orig_content" "" "empty input written" -echo "$orig_content" > "$file" - -# Test empty targets case -# ======================= - -orig_target_ids=$(cat "$DBGFS/target_ids") -echo "" > "$DBGFS/target_ids" -orig_monitor_on=$(cat "$DBGFS/monitor_on") -test_write_fail "$DBGFS/monitor_on" "on" "orig_monitor_on" "empty target ids" -echo "$orig_target_ids" > "$DBGFS/target_ids" - -# Test huge count read write -# ========================== - -dmesg -C - -for file in "$DBGFS/"* -do - ./huge_count_read_write "$file" -done - -if dmesg | grep -q WARNING -then - dmesg - exit 1 -else - exit 0 -fi - -echo "PASS" diff --git a/tools/testing/selftests/damon/debugfs_empty_targets.sh b/tools/testing/selftests/damon/debugfs_empty_targets.sh new file mode 100644 index 000000000000..87aff8083822 --- /dev/null +++ b/tools/testing/selftests/damon/debugfs_empty_targets.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +source _debugfs_common.sh + +# Test empty targets case +# ======================= + +orig_target_ids=$(cat "$DBGFS/target_ids") +echo "" > "$DBGFS/target_ids" +orig_monitor_on=$(cat "$DBGFS/monitor_on") +test_write_fail "$DBGFS/monitor_on" "on" "orig_monitor_on" "empty target ids" +echo "$orig_target_ids" > "$DBGFS/target_ids" diff --git a/tools/testing/selftests/damon/debugfs_huge_count_read_write.sh b/tools/testing/selftests/damon/debugfs_huge_count_read_write.sh new file mode 100644 index 000000000000..922cadac2950 --- /dev/null +++ b/tools/testing/selftests/damon/debugfs_huge_count_read_write.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +source _debugfs_common.sh + +# Test huge count read write +# ========================== + +dmesg -C + +for file in "$DBGFS/"* +do + ./huge_count_read_write "$file" +done + +if dmesg | grep -q WARNING +then + dmesg + exit 1 +else + exit 0 +fi diff --git a/tools/testing/selftests/damon/debugfs_schemes.sh b/tools/testing/selftests/damon/debugfs_schemes.sh new file mode 100644 index 000000000000..5b39ab44731c --- /dev/null +++ b/tools/testing/selftests/damon/debugfs_schemes.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +source _debugfs_common.sh + +# Test schemes file +# ================= + +file="$DBGFS/schemes" +orig_content=$(cat "$file") + +test_write_succ "$file" "1 2 3 4 5 6 4 0 0 0 1 2 3 1 100 3 2 1" \ + "$orig_content" "valid input" +test_write_fail "$file" "1 2 +3 4 5 6 3 0 0 0 1 2 3 1 100 3 2 1" "$orig_content" "multi lines" +test_write_succ "$file" "" "$orig_content" "disabling" +test_write_fail "$file" "2 1 2 1 10 1 3 10 1 1 1 1 1 1 1 1 2 3" \ + "$orig_content" "wrong condition ranges" +echo "$orig_content" > "$file" diff --git a/tools/testing/selftests/damon/debugfs_target_ids.sh b/tools/testing/selftests/damon/debugfs_target_ids.sh new file mode 100644 index 000000000000..49aeabdb0aae --- /dev/null +++ b/tools/testing/selftests/damon/debugfs_target_ids.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +source _debugfs_common.sh + +# Test target_ids file +# ==================== + +file="$DBGFS/target_ids" +orig_content=$(cat "$file") + +test_write_succ "$file" "1 2 3 4" "$orig_content" "valid input" +test_write_succ "$file" "1 2 abc 4" "$orig_content" "still valid input" +test_content "$file" "$orig_content" "1 2" "non-integer was there" +test_write_succ "$file" "abc 2 3" "$orig_content" "the file allows wrong input" +test_content "$file" "$orig_content" "" "wrong input written" +test_write_succ "$file" "" "$orig_content" "empty input" +test_content "$file" "$orig_content" "" "empty input written" +echo "$orig_content" > "$file"