From patchwork Sat Dec 2 00:08: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: 172724 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp1495441vqy; Fri, 1 Dec 2023 16:10:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IHg/OKREw5ImKVTGNc3YYfqEjRrhP9xXj2SFkV8bXvW8Dm4xpF0NWzYC5WcsQQ8gMTtp6M5 X-Received: by 2002:a05:6a20:3d95:b0:189:bde9:71aa with SMTP id s21-20020a056a203d9500b00189bde971aamr499317pzi.48.1701475839224; Fri, 01 Dec 2023 16:10:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701475839; cv=none; d=google.com; s=arc-20160816; b=Brj5t3Vca0E6NGcYD1hrw6faduCXXqjIezw5DAtQTGznc28HlN73BbD1SH2N30irQ5 evrF1/Pm24AgRHb/jIZJVi4s+dNgCk6RYpwhxe2U3f8b6dfpC00ubhaPB0bfxEfIzU2s Iqz7fGxvJRpWPyDBHFs/BXrWLtWy0+8O8TMOX/bC94uRMHP6JCgkD9lqpn7NoQAe4KUL 9mnDXxqDoH7Snr4E5DlKnET73qtx+q7P/kbwgQh19ZwWnot8KfVZlOwo+FNDXcLZJI0v wVioodCWO3BWsT9B2idILJfDsHk53ICddmHRYBAnys3UyroepHtIBSlU4E3ZzBzsz/MY 9VjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=FzQSkGprvCjYi1PSKTyL9VXCZYB/89pkL/cEpZOg+KI=; fh=W+de0FjxL1MlRh6Ly02q9tA2/xTz2DOJsg1VkI/mHfI=; b=WrkVg/gLARFqgRUfqmjRZsE26ctCasYhQkqRk7Wesc0LCr3yJLxvk4e2GtMzjTpeKf 2RsL+nyHLa/wH936PYkYb152Q8iRTxkiAXZedPsMDxbP6CMppjoCSeVbb6WcUy4ha1n7 8MVvVdD6LsxUiLYpBAWKbsMtDY1u70L1j/YCVo5APtwSjiP2YjTsMMnCpqinJflF+RAx FUZJIxri0jeDhbV3ilXpxZEFySVwQQoYwcgSZ3D8P/XFWsJkUpnuIxKBX+x6SZfzULry gVaAGmusea+f/4A9n54Xq/z/XDfOsyMZyPjGTHTOlPOfn3gw8b6Wnk85oBvwxkKK4u6e CyQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=eS0GQJL0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id bw29-20020a056a02049d00b005c62447fde6si4384765pgb.98.2023.12.01.16.10.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 16:10:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=eS0GQJL0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id F2628809BE43; Fri, 1 Dec 2023 16:10:35 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442003AbjLBAKW (ORCPT + 99 others); Fri, 1 Dec 2023 19:10:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235382AbjLBAKE (ORCPT ); Fri, 1 Dec 2023 19:10:04 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09EDB386F for ; Fri, 1 Dec 2023 16:09:10 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4343FC433CB; Sat, 2 Dec 2023 00:08:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701475692; bh=RPGqDNVbRfHZdHfv52ZXw/68V6PB6K+dkXKHSqnAU/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eS0GQJL0HFbLi29VHlV8HHJ66TzvYLdR6ptWgktTsJ+ve9HpARkVXJ/lTBvWM6PZ0 PcWeIAFDosQS6fItHLeCOtbITCASeM/mpK+1bIDecMd3ZDk/GHSdwSI8rnxo4RmEM6 /owzTnEWigKz9PIuqsPveep8ynF6jpKJAPEq+17cmIjo57c/pnE1yffaPTz36+nU3y OovjM/a6n6c2AdBjkFzAk9sPQdD0WWldR607zXYsbdhafadiPe8M1QDMtrlJrVqFvq k2Ig07layGEKD0GjJSSonWptIfJPglIdFsIUjlUhxMw+0sxb4t6zaS7yXbnIipwjtx r0vwISU4ttEjg== From: SeongJae Park Cc: SeongJae Park , Andrew Morton , Shuah Khan , damon@lists.linux.dev, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 4/5] selftests/damon: add a test for update_schemes_tried_regions sysfs command Date: Sat, 2 Dec 2023 00:08:05 +0000 Message-Id: <20231202000806.46210-5-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231202000806.46210-1-sj@kernel.org> References: <20231202000806.46210-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, 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 pete.vger.email To: unlisted-recipients:; (no To-header on input) 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 (pete.vger.email [0.0.0.0]); Fri, 01 Dec 2023 16:10:36 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784126729768332946 X-GMAIL-MSGID: 1784126729768332946 Add a basic test for verifying accuracy of DAMON's access monitoring functionality. The test starts a program of artificial access pattern, monitor the accesses using DAMON, and check if DAMON gets working set size with reasonable amount of error rate. Note that the acceptable error rate is set with only a naive assumption. Failure of this test may not always mean DAMON is broken, and we could adjust it in future. 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 | 48 +++++++++++++++++++ 3 files changed, 91 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