Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4878104rdb; Tue, 12 Dec 2023 11:48:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IF3x/FkDToydLsTP7CxtyktIdUSRPB768CfY9rj+5cPo8o1hmngQPhncNH0eVapn59WhAr0 X-Received: by 2002:a05:6a00:4653:b0:6bd:f224:c79e with SMTP id kp19-20020a056a00465300b006bdf224c79emr4156487pfb.11.1702410537177; Tue, 12 Dec 2023 11:48:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702410537; cv=none; d=google.com; s=arc-20160816; b=QGpFh7ooDU1KAQSEWsPNMug9OU3MdBCJ6XXowcKe/mVuvDYF87F7ozWFzQJqXsB+Za QivxCnhoVxnOaLpRG5K3jNjz5faR0E9R4r9V6d2qNZzJ0kRxX8jD7SfFQP9nxlXXPY9O TFo+ff8ac8E/a3u7vFU44GkVHTRO7ongLgwQTlQtKS4+p8cERsH8vOT8BxxUxIiAecMp STwkY4WsTihr+Lha05/CxY/Cotvy1V/4Dwvffu/oxqzbl/ubkQa7Y25JvgBNv2JClW3f 2Zd5URYQ8Xn1ldcojzWX87oq1CEiODv3qWCtZiQlAls+hBLeNKyMli44awsjYk9cdpZX 6SuA== 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=xdQBcrSzO4b/BtJyrSO+T742MLW1rQ03CSegBHQeS48=; fh=9H4z7/o7y4OLn0xLmjdSk9Pth53+ED/R+iGnGlnIr7g=; b=P+qiyz9Uj5dWJ2oGtMYk0m+aKSfuB4nFuHpgBL6cgzLu1OgqsWgCjXDzuNjGSCoaxA RRcQGyYgbwmQFYcLwRlWJApeeAYvM3O54MNv1nrkuwRYjzCs2/nvomGYnMPFsLnXOk4Y NtQwQcEm37Xq21yFUn66R6dR8CoO9c3XbtG8J2cjU3fnJqK4HXyNWVh/n8VlDryL/yWK TQxZTuYEa7NdTgBrB9xQqVGX2V5HOMTTxLJQCOyJciwpXlNrtWLeJMctUE/82cHUtkhy TrLPr4HxYsh0YNvQVuk0dzBmNjNkWMqgYXXmxlNVulGx1QHTZB7AlOtmbTFycP2G2Jdn X5fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oFG5wkkB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id ka41-20020a056a0093a900b006cd8db94631si7915007pfb.365.2023.12.12.11.48.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 11:48:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oFG5wkkB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 2B25780F926C; Tue, 12 Dec 2023 11:48:54 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377301AbjLLTs2 (ORCPT + 99 others); Tue, 12 Dec 2023 14:48:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377305AbjLLTsX (ORCPT ); Tue, 12 Dec 2023 14:48:23 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE48AE9 for ; Tue, 12 Dec 2023 11:48:28 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0450C433C8; Tue, 12 Dec 2023 19:48:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702410508; bh=phkCbBjwGt+n6h2sfVSgzetITkrs0kG9itajhDj2yNo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oFG5wkkBOF2x9j9gyGGLubTMYkzkbJstAmoQ25ym5KEkYMW7LQSg7VlkHT0VsBewq PNQQrckZItir6nXXD95z1008764sdQl/AiClTuGyEzxA+qnRMrnO9PCNHTged7xwEN qCSwu9EgddoVUVOAvIS6hDQt1O2WtLZvpLEv08pY3pxg/Preb3AwtoWheHB9hto/QU r/phUw+qZQTWEpXEvJVsB79kWl/o/4LLOYYtZJYxFkXkSaVxiOMAmTyP6xAwrhuHSp BXq//Pn/qh8xeJ9APQLYtPyVUMvuu0BYixIg+JQAUvz+QOwPAJVfOO7SECXW7UgdL1 XHNxiSAwN4dxw== 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 v2 4/5] selftests/damon: add a test for update_schemes_tried_regions sysfs command Date: Tue, 12 Dec 2023 19:48:09 +0000 Message-Id: <20231212194810.54457-5-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231212194810.54457-1-sj@kernel.org> References: <20231212194810.54457-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 morse.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 (morse.vger.email [0.0.0.0]); Tue, 12 Dec 2023 11:48:54 -0800 (PST) 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 b71247ba7196..90ffafc42c5e 100644 --- a/tools/testing/selftests/damon/Makefile +++ b/tools/testing/selftests/damon/Makefile @@ -2,6 +2,7 @@ # Makefile for damon selftests TEST_GEN_FILES += huge_count_read_write +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 @@ -9,6 +10,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 include ../lib.mk 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