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: 177525 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7944328vqy; Tue, 12 Dec 2023 11:12:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IG4txyss13dG2VAax1S7mLieFSCloywXJG+i+skuR2lWjrCImRqoiWWRhL5T6jbiWYCQ7al X-Received: by 2002:a17:902:da8b:b0:1d0:6ffd:e2b6 with SMTP id j11-20020a170902da8b00b001d06ffde2b6mr7036973plx.80.1702408370157; Tue, 12 Dec 2023 11:12:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702408370; cv=none; d=google.com; s=arc-20160816; b=BT55FZB7FKhFhv4XRzy4RTRlUHEU6oksHjtqs6ownQg15mzl9Tv1buQbGAoUpSur6t ubvs+nEDB6SOUmfgIdD+h5wP3OKbfsmRSToKuGo7poPdKUB3v+FGVCnivmzq/3FcfiNP C5GB8i4q1+VM/Zla8yENJsQl2ZpSuai8ixqzhiHF+IwrxBesVB5kvUeZy12L0msu3po0 HyjigvpH9eCC19Va/vDoTRVlf0MSUkDJyBMr0gakwBgOk/E5be6iNUoVM8wxZ2QAJMLd YPTtxCdy6gnKjrm2BgZIfWN9ZBN1RSABqLJmnDa3BENZWKHVho1sRCD9llwKciuOl/xN 8SiA== 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=3VJ726YN6plBtchnpzMPTU6q7cVzWCsC5Cn68VzccxA=; fh=9H4z7/o7y4OLn0xLmjdSk9Pth53+ED/R+iGnGlnIr7g=; b=oDgUQY4fmMAKIit0AUwxlNKf0Z2DV3lKRgyDxtHZJZLE+ChgHdD95ztxQYY4egNdDM w+6fPLAcMK1352jzECwc7hqYOf08E8AROJ3OQu0prNEeN9ALltNdrU/PNqoo0PD9ngyx 7W5kd7msz92XjaGVm3VH0zwhVUZLfK0jEPp4wytYfTWNXVFOz+cE3Duez9oLkROA1E2R F3LMujr+YN4kgfpMS4XPKkLH3pEUnjpHBoYNOP9c5ppLS5z3lzR7qzstriVB3hqWmkWD B+erdhKFjVcwqyDhNN+k7fOpZkfz+RsWOoZrMiQ6MeLNxv0PNLyMuWXxCBEbV4/qDCgn EX8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ogvwZ8Mn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id x3-20020a170902ea8300b001d07490028bsi8173052plb.178.2023.12.12.11.12.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 11:12:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ogvwZ8Mn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 2449C80A90E2; Tue, 12 Dec 2023 11:12:47 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377197AbjLLTMS (ORCPT + 99 others); Tue, 12 Dec 2023 14:12:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377118AbjLLTMM (ORCPT ); Tue, 12 Dec 2023 14:12:12 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0F60AF for ; Tue, 12 Dec 2023 11:12:18 -0800 (PST) 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-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 12 Dec 2023 11:12:47 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785104558686696667 X-GMAIL-MSGID: 1785104558686696667 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