From patchwork Tue Dec 12 19:48:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13489829 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 13A7DC4167B for ; Tue, 12 Dec 2023 19:48:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 371BE6B035B; Tue, 12 Dec 2023 14:48:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2FA266B035D; Tue, 12 Dec 2023 14:48:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 097FC6B035E; Tue, 12 Dec 2023 14:48:36 -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 E1DD56B035B for ; Tue, 12 Dec 2023 14:48:35 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7969240A5F for ; Tue, 12 Dec 2023 19:48:35 +0000 (UTC) X-FDA: 81559203390.25.C9D328E Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf01.hostedemail.com (Postfix) with ESMTP id 0CD4840007 for ; Tue, 12 Dec 2023 19:48:32 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=oFG5wkkB; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf01.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 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=1702410513; 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=xdQBcrSzO4b/BtJyrSO+T742MLW1rQ03CSegBHQeS48=; b=Nll70lzakeEpxNXLoeWGnT7MS5MHz2xur2iWfuZg4L0mvVs5oeQSWHAangcjuzo2GQEHIv +2amJVLJDsUCBY8i+RRT6Y49PvXz16LldYM7vFmYXbY3WKe+MZBb/ig4HKSgxo/rBewFM0 hnEphsQwjax7hWVxdd+cFFi3jgyrsFM= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=oFG5wkkB; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf01.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702410513; a=rsa-sha256; cv=none; b=P0vP/UztINFZzDIcYXAJUn/25T3C0GIRTp7OU4s3y52nl2SU/YY5Ukrmjs0bubCdiXZaYZ ygjk0YID2GBF9m2LN1aUuRU9eoHY9rHcuekFPXnkpbNqCmOSRM/QUMA/ttHdVCo3ie9juN clsSfkgAWJCHb4OwHX0BWTmmawROvKs= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 4DABECE1B9A; Tue, 12 Dec 2023 19:48:29 +0000 (UTC) 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 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 0CD4840007 X-Stat-Signature: do63ip45bssaf37yhcpd9rb4yn7f4h7n X-HE-Tag: 1702410512-446319 X-HE-Meta: U2FsdGVkX1/wHgYh/fsMAzoWtTRY0UxMoF4ZhycUSybnXWgjEgS5GX0AGjLz3fz4EFqbRNf23RqUK/Z6mel58CwW/HuYSi5dGU0luc3IIMFClY/kV5VMcIVlCadlB63gdGdDgYVDllEXT0x/UOztazjYq2uvZ9uVlFtJ0MUPG6yrXEhxVuVCT2SHng5xVO5ffgRaFdwFHw26/laVZ+CFYrOFWu9c2FmFr2i5Uh+JlYN89szrePo3t+dvzz1nlbr6Ecwcne8ACT3mS3GBVYMnsZ7YqZNNMe6SABbxCxC+v8+CmZzmbIL3LLUZXM96YqoHGCBiBcwWXtT0/gUi6G9bsUn2sp9b0WiBTi5OY/yGjD1/N6OPeby7yM6XXzLAnkXsOpLqvJCFZMyhciBZ9IohsGPvXPs8fmnbdWOwimsqXS60rKr7dy0tCEfW7OmE8ljccgXFy8RIQZN6AtgGqpvUmZYIjb6ZW+2oCKyhk334pN/OkEHOno0VzQEpGhyFz/oVUL5zmlAwblZgU0az21R4+XFz7H1Rsno6rjOS9Dj3uImGNmrozOvpIIcKsCmFq1qAvlGJS3oBb3dBe+fVZ5pLEx6GS5na9FvVWLG8KPrRH1zuCCkq500bLRZRbKNYyGql0v4wBn20q6oksSGMzp8loTrDitERtJdOWDN85ScyXjJHINZ2GvkBSGgcZegH9YrMVbTNxaWeuXpRs3dMBdQISlQwy2XgPODL8KwCL/WERY4Voe6D3NHqu1VC0mwEUrcgrmqE2GOpP6z6Rh+mX1vZDxNL3o4pR2SxBbXgqV+j07AE+QTFtBIR1GCVAkdwlLx2RXLKp5yUxueKKhYRl8RcX3tieadnS9PwePHrPfkcV3ejmv6vW1kXYc5CXj14rIF55nolv+oMyrWvaIGTZowFsrXt1PotqnrUVW6pL25gwDmhX3OxmzSAZj9soSGDgjSmFhdRyZq4Fqhqdev1ijY nmNvcJXP RHzpG0WCB3KiforhF0x2IK9K3q3IG0xbrQSr/Ja0r9IUjxB3z7uHWkdusX54Kqx9bY3tnbymRk4OWBZPEqi1udy3dZqsqCki3WMJWxL7R5DcP+jwLdlGq4/dZKkrQj5PpJnY6gflFC6WiMbNnVta5BAxtCtPIDVa3OAfKBJpe1TuofoslIkvn7jai9itLAMJwQt4+Yl6EIZ1gyzWyJNPmblNk/Q8JsKt98qD6vZGhCM7kfnQwUI5mkEsXzUFXwQn/4QB/GGWLDPl5Thbfppb7CN7OLMlEIX/QhtBx 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 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