From patchwork Tue Dec 12 19:12:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13489786 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 BBAF0C4332F for ; Tue, 12 Dec 2023 19:12:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 995D46B0339; Tue, 12 Dec 2023 14:12:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 85C686B033B; Tue, 12 Dec 2023 14:12:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 610846B033C; Tue, 12 Dec 2023 14:12:21 -0500 (EST) 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 3B29D6B0339 for ; Tue, 12 Dec 2023 14:12:21 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 196C0120622 for ; Tue, 12 Dec 2023 19:12:21 +0000 (UTC) X-FDA: 81559112082.22.74E6D7D Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf26.hostedemail.com (Postfix) with ESMTP id 5766A140016 for ; Tue, 12 Dec 2023 19:12:19 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ogvwZ8Mn; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf26.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=1702408339; 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=3VJ726YN6plBtchnpzMPTU6q7cVzWCsC5Cn68VzccxA=; b=PJ5feAkMthT8oW9+S14qLzGub584Pusb/5rawirkwxbJTb46ZVbNXvKWgGg5yUEJfFQ5ZX fKjOaN5SPQckUuFbjmbU860ilnqNLqPkoBDIJF1JkXLf2YYapbTTaav1xjJg+tNqi6wYof eTmFi/HpE4aNtl96to2FWUlMCNM9AbY= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ogvwZ8Mn; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf26.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702408339; a=rsa-sha256; cv=none; b=QcA8C2ZnRmHCkzVI1/mV+ltB+toyuFR8goUE2zrkMc5Mn3kDToyUL6yljPEZ4A4n65eVzS tsNkmglUXHoXhYcJKrISzLKk8vzJd5CA0brh/XLBQLFrsI4hLjBL2q+dBlGkYb4twO+vj1 M9h0ksCW1zgiBuQ+xHjadRcqIUcejc8= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 7F7D360F59; Tue, 12 Dec 2023 19:12:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BAEBAC433C8; Tue, 12 Dec 2023 19:12:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702408338; bh=Nae8nBQge9ILU6mOkKP2BWSbfolFXrAD4ZUt2jzv2tE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ogvwZ8MntEnfHRb+BB81wAbNlQrUsGfiI02mB3lXfwqqxzVxq0LV2k+kUXz9bjedX xpR74JJercrj9aD09mx99JV8Cx44NCcQHbEEsd2yHf+iJyduUkZrw2xRveOHsBqS0S neGGA6Gg72oX/Rr6gP8WitqOUuCIYSSOvdwQ/7k8wyfrwcx0CaH9KVzMhYfDB8HTuq knP81Jn2ELPbWLrbC7o3RDxOGraCLtOJsiqrSi3AClriuVx4Aijrvqm4Bz+OJJnr53 Tep0z/RiPk92+WwbzKVlV3HSOXsIvFvx12hXqzbOuj5hIOfYx0oPWubYFS075bgYm0 CEauJGxnArJ2w== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Shuah Khan , damon@lists.linux.dev, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/5] selftests/damon: add a test for update_schemes_tried_regions sysfs command Date: Tue, 12 Dec 2023 19:12:05 +0000 Message-Id: <20231212191206.52917-5-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231212191206.52917-1-sj@kernel.org> References: <20231212191206.52917-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 5766A140016 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 5371z37ykytq1r4ra1wccaqc4om69jaa X-HE-Tag: 1702408339-240001 X-HE-Meta: U2FsdGVkX18ssNb1USfPROnliXPGRlS+SM3EfAKKdBvKr0WbtrtZ9k6BLV43yeO/sT/DocSCucTsY2OHutWKY7llN3Sbvryp04RgkZ0Uoc3oIn7qcpXrHCA4/roDd7OfeGq295VzuUTNxuYJrFR9K0suRRcFy7nvf7oxOWq+8g+qCCP6tdrAguroFEb+SB4bVzTxnYGMili6GLHPkxhD2j69OYiL9eELcXTE6cBIb8uGylcQpqwND+NctuEm4vFOmh4VuNMA14fkyhpr/fLknUcsecnFxaIOEjwrhFF0YzLvaIv74Q4Y4jsDBUq64JAM+MlbHKxR5q7sXVqa/ySk9xvqIha64fBZS4Yhs5UEJwWQnkQJKZafD0Ytnb05v+gxOUydqdhBzJWUmWTPkBc8vignT9PHsUugwVxkA6Rb8gEX4C5S6F+Qw8TEQNNYfF4sTSx3nvcP3AT7ptM3QOt5CMPPvC2ciU/hxyMQPxgRltUfejnjaVBPEfQ4mkMrjrGVAnutnNSbPb846kkuuyhp+/9AmYAjzkV1u/Er5WlmAsPf+saREsOO0JupUf0uiWptI24c+QbXd+gmbOU5ncyKzjCu2hykwI5e1ES4YIiPiFmc+k/++OzwsX+kJZzeO4A2m8Zy6VNPBXsndZOL5NSp6/LNSOG+fJzTfulREEoTPgcBwCdiuUYPxU+PnSYPvPifPVdmxi3cyySBDXRHy01GdNrBOqq7zr7Ket5hXJ7OQQp4plSoyV6pbBbu6zwzvNWXmGUnWEMDugMtwcxv8YY/sPuf7A9V5dKbKyvXd6ehDeAX4cW079ZtvKH6mnXJtdJB2qZRzvptTIINAX6CDPJ/6ctQKkRJFpOdZHOtnih7RmQq5g3oGavfHP+JWNqQGTF+2m9WEpNrSeJ3Jf+ujC764j19WWSlMLNYNu+FmeEFWWQPHytG7IiP3YeUwPsXoFkMwwuQzTvwnbgxbYph+zG 3LHeWuec 5cppTBJbw76Iyxt4D3q8SFOOJzu7CKNd+LFA5N7UeKTDxHrzGrnIQYQqW+JZmWgI84UBpbx78PE0G1DMrNrXQp/ZnexSmPlBd7ilo+kIy7rrF2rqjppnB+JXXjSUpSIcvY9q12PB3WhCpO+97KgMJU5W1d0I/ROL976NwDCv4ZGS6kgGDqF+h7g/bNE6GK7SKl1AYzk+4Ttf8GTBu7nl1KL0v4Xny1jcK0LRyHDbkZLQpAvnFvxvfRxnsmSXDKp/taM8PjJ6LMaN55H1gva8yiYu6w83rQEs5xu1s 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: Add a selftest for verifying the accuracy of DAMON's access monitoring functionality. The test starts a program of artificial access pattern, monitor the access pattern using DAMON, and check if DAMON finds expected amount of hot data region (working set size) with only acceptable error rate. Note that the acceptable error rate is set with only naive assumptions and small number of tests. Hence failures of the test may not always mean DAMON is broken. Rather than that, those could be a signal to better understand the real accuracy level of DAMON in wider environments. Based on further finding, we could optimize DAMON or adjust the expectation of the test. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/Makefile | 2 + tools/testing/selftests/damon/access_memory.c | 41 ++++++++++++++ ...te_schemes_tried_regions_wss_estimation.py | 55 +++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 tools/testing/selftests/damon/access_memory.c create mode 100755 tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_wss_estimation.py diff --git a/tools/testing/selftests/damon/Makefile b/tools/testing/selftests/damon/Makefile index d2105d41ea25..1363987709c6 100644 --- a/tools/testing/selftests/damon/Makefile +++ b/tools/testing/selftests/damon/Makefile @@ -4,6 +4,7 @@ TEST_GEN_FILES += huge_count_read_write TEST_GEN_FILES += dbgfs_target_ids_read_before_terminate_race TEST_GEN_FILES += dbgfs_target_ids_pid_leak +TEST_GEN_FILES += access_memory TEST_FILES = _chk_dependency.sh _debugfs_common.sh TEST_PROGS = debugfs_attrs.sh debugfs_schemes.sh debugfs_target_ids.sh @@ -11,6 +12,7 @@ TEST_PROGS += debugfs_empty_targets.sh debugfs_huge_count_read_write.sh TEST_PROGS += debugfs_duplicate_context_creation.sh TEST_PROGS += debugfs_rm_non_contexts.sh TEST_PROGS += sysfs.sh sysfs_update_removed_scheme_dir.sh +TEST_PROGS += sysfs_update_schemes_tried_regions_wss_estimation.py TEST_PROGS += reclaim.sh lru_sort.sh TEST_PROGS += dbgfs_target_ids_read_before_terminate_race.sh TEST_PROGS += dbgfs_target_ids_pid_leak.sh diff --git a/tools/testing/selftests/damon/access_memory.c b/tools/testing/selftests/damon/access_memory.c new file mode 100644 index 000000000000..585a2fa54329 --- /dev/null +++ b/tools/testing/selftests/damon/access_memory.c @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Artificial memory access program for testing DAMON. + */ + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + char **regions; + clock_t start_clock; + int nr_regions; + int sz_region; + int access_time_ms; + int i; + + if (argc != 4) { + printf("Usage: %s