From patchwork Tue Dec 12 19:12:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13489784 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 0E9D0C4332F for ; Tue, 12 Dec 2023 19:12:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9904D6B0335; Tue, 12 Dec 2023 14:12:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9400A6B0337; Tue, 12 Dec 2023 14:12:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7E11E6B0338; Tue, 12 Dec 2023 14:12:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 5D7AD6B0335 for ; Tue, 12 Dec 2023 14:12:17 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 23753401B4 for ; Tue, 12 Dec 2023 19:12:17 +0000 (UTC) X-FDA: 81559111914.09.43C930D Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf27.hostedemail.com (Postfix) with ESMTP id 37B4640002 for ; Tue, 12 Dec 2023 19:12:14 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=igSIjbck; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf27.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 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=1702408335; 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=fi3wGtfhWzp/nJ5/3E+L/QGAOBlEEdfPp7Moh7rrm4k=; b=IohiTLXzc63idDbi5E97mr/0AOXJtg+2XEn796bDTsXl+19XUpcv9kMPwJxNEfFyiGRJLo S4ujw0Sn9z8iMqySHoksC4zl+aR5NxhcLynd4SLyG4L6ofqJQ4kZaxxeOWmBXEk98/B316 YJhFw9i5EXnusylJq5I6dDcyPOt67RY= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=igSIjbck; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf27.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702408335; a=rsa-sha256; cv=none; b=sLI/8Ay2BWraVbuqUcG4Ht5XAiWyWUMVf+lU/KZkRTutwdDz9yJK3OunXdhP9bOwJUMag6 pNRgmomffhbb4NtJ/CU4D5R9Hbt9Q/P8m0BQ4ELUkFCFaqJzRbvdCrzEYB1421NOgwZyxR wJv12QiVdCxls69ooyjedMXc+2F0N9Q= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id D3BEDB81892; Tue, 12 Dec 2023 19:12:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A235CC433C7; Tue, 12 Dec 2023 19:12:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702408333; bh=GHi4Mu0bQn8zyIS9XnsaUAW8ixexoLEYfp8Ut/tF7Co=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=igSIjbckp2hVl7FoDQk0XpOqN8qpCWR+x4WM0LuOXFbwy7VEp+1mpdVGEp8BgivFk YWuKoyLk6+L92fw8DO6z/SjD/Age3Nw8aFN3sUTuRzQgQjSwqpMMH4MFQTfv9gsTfK 0yQ9XH+/wMbWvMMsVUweD+5+gttAd05TAPRCtqgaWwxz119gLLW0XT1drB4JssYga9 hUo9zJVevAPH1Y6xLxnsPPmQ6jbZ4y880MruyyjZJ+eCpF19hzXMTF25lBB45kswHv hg9DjEcyWnOzOwBRp0kdHamLzLcQIb5sDCdxJcPFu+s41K1wSzza5v7T1AmYPl9he3 9OpPFk5S2jV4A== 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 1/5] selftests/damon: implement a python module for test-purpose DAMON sysfs controls Date: Tue, 12 Dec 2023 19:12:02 +0000 Message-Id: <20231212191206.52917-2-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: 37B4640002 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: pinncegrr1szzzoo5z8jy7ff94eunzpn X-HE-Tag: 1702408334-435281 X-HE-Meta: U2FsdGVkX19PGn7Aczl3QAbvg1H5dx9rHDwLj+UU09R2xgVwVUR8u/SnYMwQ7GahX9eeU3kO7WBdiMtQheFGI6lyOZv5qxbUYOFw3C3fIN4rcfxhIbGPDqikW8/4GC69nS59M2nN4WB9ODTLMebUe1PsWvdsZKBt9+cqsrXbwumY9De0lBUH2nT+g94MqK6ZL4FPVGdBDgmkuAEtDGTpXfsXaf6ZMm5WExeuq07HYtdwojpVyfDA2RP0l8kvEUsCii2rkRm+qIIiUyUkZUonoxqYAMrI2PFRVcjVy5qoHULsN78lH9JyD8EtjmJ4wYMtfJlzt1F1ClV/ooilLVdOE7B1qpbwVsX7ebgnRfzEil+RXoabb4bEO/GYOuNs92NHvKIO6WMvZ+W3MSY2RIJ6Lu5mcTNCse9Ixf12OPQl6Zf9JmQ+j4N8LGn7n7iDVLa4CZHCqomgtiFyZze238bNLhSYJl8vibidencidtCn1iTt13GJjTaRylbFL2Oe/zwBepHa6ph2ImOzsel2PWqXUkzoEgpMTiLiSQKJpAIpckfjiyenfuzg9xpJL5BT6OD80OhOP5kTwQMCSvSdkK0mx6wd9CHpipv20b4xm+daISD2KhBOInwtBNmKUEP8hhCi6geGVFKqjzXuhe4WxGxyUBVY0FSVTvF2lzXATPsMvHTE3VWoy3GXYRwOOqxELkohinZ/gRmu1VPpF8m7SgldvrG1CWA96bqSAaWtn34XWZ0xuAgA3ZLpHugMqQYtnsMa87AFEBhJHpIlTe0/kZ+wa8UWm6IdHaEdHds9tDsRhH7EXFJi6sM2d1bcGuOFxXA/+sopCbLrCgPKIwwFCGSTGBRtjd5EaT9GpU/NmO5SrhY1p2BEHqgRPO8uFFvrIsfVdsB7lFHokd4B3FKJA0feku2QDxtVDApn7noDkvWwdcsYA3MP9YUqJ/s4vO4yYqeFRL5TsNOZmibOpoX+rHu VC6t72jn VJyEMLNJX4gfCQ8dmcvJ3SVr5VjXG1omvR/D7jFZP+/HMzqRluAk7ogrWB4E837O/Ylf4W7yrrKhpqhH3CUvzGRZ0QVuC/ACvAqjg/CVeC/FXlNyfgwRDqV57Ec2imvAWQFAJVBx3bfWNGLwTUQg02xE8lVxoWjEBD2Xj45w7EYiGw6fXtwP/tmCk2Ct98tFZFHYEeDyE+H+v9v1+XlEE/4ssX8tJxfcMrFXB74FLiKnbl7M= 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: Implement a python module for DAMON sysfs controls. The module is aimed to be useful for writing DAMON functionality tests in future. Nonetheless, this module is only representing a subset of DAMON sysfs files. Following commits will implement more DAMON sysfs controls. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/_damon_sysfs.py | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 tools/testing/selftests/damon/_damon_sysfs.py diff --git a/tools/testing/selftests/damon/_damon_sysfs.py b/tools/testing/selftests/damon/_damon_sysfs.py new file mode 100644 index 000000000000..78101846ab66 --- /dev/null +++ b/tools/testing/selftests/damon/_damon_sysfs.py @@ -0,0 +1,102 @@ +# SPDX-License-Identifier: GPL-2.0 + +class DamosAccessPattern: + size = None + nr_accesses = None + age = None + scheme = None + + def __init__(self, size=None, nr_accesses=None, age=None): + self.size = size + self.nr_accesses = nr_accesses + self.age = age + + if self.size == None: + self.size = [0, 2**64 - 1] + if self.nr_accesses == None: + self.nr_accesses = [0, 2**64 - 1] + if self.age == None: + self.age = [0, 2**64 - 1] + +class Damos: + action = None + access_pattern = None + # todo: Support quotas, watermarks, stats, tried_regions + idx = None + context = None + + def __init__(self, action='stat', access_pattern=DamosAccessPattern()): + self.action = action + self.access_pattern = access_pattern + self.access_pattern.scheme = self + +class DamonTarget: + pid = None + # todo: Support target regions if test is made + idx = None + context = None + + def __init__(self, pid): + self.pid = pid + +class DamonAttrs: + sample_us = None + aggr_us = None + update_us = None + min_nr_regions = None + max_nr_regions = None + context = None + + def __init__(self, sample_us=5000, aggr_us=100000, update_us=1000000, + min_nr_regions=10, max_nr_regions=1000): + self.sample_us = sample_us + self.aggr_us = aggr_us + self.update_us = update_us + self.min_nr_regions = min_nr_regions + self.max_nr_regions = max_nr_regions + +class DamonCtx: + ops = None + monitoring_attrs = None + targets = None + schemes = None + kdamond = None + idx = None + + def __init__(self, ops='paddr', monitoring_attrs=DamonAttrs(), targets=[], + schemes=[]): + self.ops = ops + self.monitoring_attrs = monitoring_attrs + self.monitoring_attrs.context = self + + self.targets = targets + for idx, target in enumerate(self.targets): + target.idx = idx + target.context = self + + self.schemes = schemes + for idx, scheme in enumerate(self.schemes): + scheme.idx = idx + scheme.context = self + +class Kdamond: + state = None + pid = None + contexts = None + idx = None # index of this kdamond between siblings + kdamonds = None # parent + + def __init__(self, contexts=[]): + self.contexts = contexts + for idx, context in enumerate(self.contexts): + context.idx = idx + context.kdamond = self + +class Kdamonds: + kdamonds = [] + + def __init__(self, kdamonds=[]): + self.kdamonds = kdamonds + for idx, kdamond in enumerate(self.kdamonds): + kdamond.idx = idx + kdamond.kdamonds = self From patchwork Tue Dec 12 19:12:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13489787 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 A83E9C4332F for ; Tue, 12 Dec 2023 19:12:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7E3766B033B; Tue, 12 Dec 2023 14:12:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 796936B033D; Tue, 12 Dec 2023 14:12:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 60DDA6B033E; Tue, 12 Dec 2023 14:12:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 4B7416B033B for ; Tue, 12 Dec 2023 14:12:22 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 25C7EA1EA1 for ; Tue, 12 Dec 2023 19:12:22 +0000 (UTC) X-FDA: 81559112124.08.4CBCC4E Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf23.hostedemail.com (Postfix) with ESMTP id D5953140019 for ; Tue, 12 Dec 2023 19:12:19 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LRYglFPH; spf=pass (imf23.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702408340; 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=Llj595fCp/6fkqvOsmjH1Ip3cww+RZOnknJ+I9nFpd4=; b=P5hJrLUaMpkhGPuo7/S5ZbTadOvAgDU7qyoFuOok1G+0lEZt+ae0btxWEptBXfdghf5bV8 W0m8f6vVIl5VuXmd2DstkBMQwpAWbw6JbZ31sI3YG7+wo+hORpF9KFYe04xExdDNYxA78r /m7dR9hoAu8q255HoaqlzNfvrBrNUGE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702408340; a=rsa-sha256; cv=none; b=jZnFLVpGsjGWKNIwx+OsPo5T1BDTwbcLW62EOUJYpD/bvMdJavFUKXJXkUCgUSiId0BTzW c+aRo3E4lRNvg6tEbgNdSRnfTgaP0CH37RbfoQiJImTqVYQFINRjAsWxwlWjnH4oeVHlIT xdzOdF7kTZDvJ5qCJAEKS7/C/inqU98= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LRYglFPH; spf=pass (imf23.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 1C3FCCE1B96; Tue, 12 Dec 2023 19:12:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0459C433CA; Tue, 12 Dec 2023 19:12:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702408335; bh=DR2Fa3ovjeZyoem+oDl1suN899iJhJUC8UTSzsABCII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LRYglFPHtFeydr48Km9Sa9erA75e8UthD942v4D8hIgASGiY2dwkC4QPS0tMb9Gcr 9e2sSgB1CAt6n4QLv8UCVbDWbcOw6TbbftaAttRkPsNY82glveOXuyIzrqT3T85D8c isiteR6bbcdJbOmGNTNw4+eY0U/SNqwAnB2f0vaneU2EigtbDeED26FrMoPMcIEHwe 3vstJeiNPH1GEP96vBMXZ6C0hZ2L9Y1ZlrfwWCqZEFyUvc0HyyBG4a9plrX1lETL7F /QYp97YiJKgnXVIy0g5DDefUk3RrahxMjmtj6c4K/VEoC7nXueQd0yeepxcdwX0uHe Et1+MU2vMFUUw== 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 2/5] selftests/damon/_damon_sysfs: implement kdamonds start function Date: Tue, 12 Dec 2023 19:12:03 +0000 Message-Id: <20231212191206.52917-3-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: D5953140019 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: p83mhoaa5xzwmgcgn6713mf6g6tqbckb X-HE-Tag: 1702408339-867582 X-HE-Meta: U2FsdGVkX1+QwijRgRdqYOHNnxZw2zfY80ef/qYRTJWZekPcLy2SdO9cZQL55g00Nw491c2lBtWQsCeQCa9JpkDUH1FU0wImBkD+rNTQdfKq5/uWKnyn81PulWx/xdFgy6gg92mwtBArNb8OxlK9jmdQv0uckA/9RzAz+eZ5GmksJhepT+H57xSOIAWTUBfS8tD5Kcre8nIX5Vk4dAPp8PAiy0LPKYeYui2zVboq+tWMkz5DebQgIXG6+VEGnRqj77LRUypd28ZVSGZCeA5J4TkZPSJ/aJ5szXybpoNXw1QOUUXyd9Sb1/hCfiDwS+XmZNqEJPxekMwryz+nZy5Ph4O9E4Xo0VXfSndxKxCofVtu5s9ioT+2RNFlM49GSTWBHaPsU/gzyPQVTDUrwUhmzUTm6cWr/s96n6dXg8MxjX2WP0AdYMwvv8WZ++eNSEKsXpUTECYxHP6n7ENct5ZJnmVcXifukYBJM0xatVIzImT3NOzOLBCWsAqWtLA5+iD1Lgx9Yy0dOxvj+W1EPtMTgcyi08AZ3wsoM6Z2MClyaK0lDkr3VHdahjPqzsNA/PcuSg5JMuOd25nvZNlOZ0azWHyPV4xrnN5SVCEc2FhPpNOC/BuGmKpItcudVgONpo4T3jLCNp/R8RJWTTN0fShr8Wyi+/rEZVNXPhs9iYkfS1Tce9JdWFkq3n6TsKQ8tEBnMRqlrOfCQfmxAkHBmDiaVcibFzuUJsqAAVanXYaK4plrIF3eoY/oByrBzk+Dq7NzaGkYbvO3uSScE29qxGT81zhr84+yPkLlDbWTci2J1maPEDQn+9cibdTmQAW0ms3xzk/j6ZOdIPAEMceiZKJpJQN5Fdg2EnrQ9oY1GZBY4on7YlOzObAR8BTFsKGLkpdmO1h8snoQFD5R7wtk+qpaHSRwa7SdRaUMTzj3yPCCul0uDTsYK3KPrB50vvz3PiCat+IcCDEF+VCDr6Ogg4U blFjpkiI UOQEYL+QpKT3oV1X/HL4H8j3aqby9XavwrX8zOgOe6Heqa338eIROfo0bI7Mj+tOJJpc7dmxyWbZ7RN3BBGYeiDN/tssP/+AdJYhxGK2bnGzedsNUOQcwgudWR/zGQN9eKC8yChF3rrvlgtGCg3obxH18LUgMlm1/xIewxTZ1z+jOuxau7o7GSPsRQ/N+TqwqHH+r3HYA+jtzHsL6sQztrDhBvCOv/p1PpbMjLMK2wi8yyRk01sjB0rcx8vyuJQv75KZiY3niiRXVW2rTy7adDUUsKdNpm8wu369r 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: Extend the tests-writing-purpose DAMON sysfs control module to support the kdamonds start functionality. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/_damon_sysfs.py | 206 ++++++++++++++++++ 1 file changed, 206 insertions(+) diff --git a/tools/testing/selftests/damon/_damon_sysfs.py b/tools/testing/selftests/damon/_damon_sysfs.py index 78101846ab66..6b99f87a5f1e 100644 --- a/tools/testing/selftests/damon/_damon_sysfs.py +++ b/tools/testing/selftests/damon/_damon_sysfs.py @@ -1,5 +1,28 @@ # SPDX-License-Identifier: GPL-2.0 +import os + +sysfs_root = '/sys/kernel/mm/damon/admin' + +def write_file(path, string): + "Returns error string if failed, or None otherwise" + string = '%s' % string + try: + with open(path, 'w') as f: + f.write(string) + except Exception as e: + return '%s' % e + return None + +def read_file(path): + '''Returns the read content and error string. The read content is None if + the reading failed''' + try: + with open(path, 'r') as f: + return f.read(), None + except Exception as e: + return None, '%s' % e + class DamosAccessPattern: size = None nr_accesses = None @@ -18,6 +41,35 @@ class DamosAccessPattern: if self.age == None: self.age = [0, 2**64 - 1] + def sysfs_dir(self): + return os.path.join(self.scheme.sysfs_dir(), 'access_pattern') + + def stage(self): + err = write_file( + os.path.join(self.sysfs_dir(), 'sz', 'min'), self.size[0]) + if err != None: + return err + err = write_file( + os.path.join(self.sysfs_dir(), 'sz', 'max'), self.size[1]) + if err != None: + return err + err = write_file(os.path.join(self.sysfs_dir(), 'nr_accesses', 'min'), + self.nr_accesses[0]) + if err != None: + return err + err = write_file(os.path.join(self.sysfs_dir(), 'nr_accesses', 'max'), + self.nr_accesses[1]) + if err != None: + return err + err = write_file( + os.path.join(self.sysfs_dir(), 'age', 'min'), self.age[0]) + if err != None: + return err + err = write_file( + os.path.join(self.sysfs_dir(), 'age', 'max'), self.age[1]) + if err != None: + return err + class Damos: action = None access_pattern = None @@ -30,6 +82,39 @@ class Damos: self.access_pattern = access_pattern self.access_pattern.scheme = self + def sysfs_dir(self): + return os.path.join( + self.context.sysfs_dir(), 'schemes', '%d' % self.idx) + + def stage(self): + err = write_file(os.path.join(self.sysfs_dir(), 'action'), self.action) + if err != None: + return err + err = self.access_pattern.stage() + if err != None: + return err + + # disable quotas + err = write_file(os.path.join(self.sysfs_dir(), 'quotas', 'ms'), '0') + if err != None: + return err + err = write_file( + os.path.join(self.sysfs_dir(), 'quotas', 'bytes'), '0') + if err != None: + return err + + # disable watermarks + err = write_file( + os.path.join(self.sysfs_dir(), 'watermarks', 'metric'), 'none') + if err != None: + return err + + # disable filters + err = write_file( + os.path.join(self.sysfs_dir(), 'filters', 'nr_filters'), '0') + if err != None: + return err + class DamonTarget: pid = None # todo: Support target regions if test is made @@ -39,6 +124,18 @@ class DamonTarget: def __init__(self, pid): self.pid = pid + def sysfs_dir(self): + return os.path.join( + self.context.sysfs_dir(), 'targets', '%d' % self.idx) + + def stage(self): + err = write_file( + os.path.join(self.sysfs_dir(), 'regions', 'nr_regions'), '0') + if err != None: + return err + return write_file( + os.path.join(self.sysfs_dir(), 'pid_target'), self.pid) + class DamonAttrs: sample_us = None aggr_us = None @@ -55,6 +152,40 @@ class DamonAttrs: self.min_nr_regions = min_nr_regions self.max_nr_regions = max_nr_regions + def interval_sysfs_dir(self): + return os.path.join(self.context.sysfs_dir(), 'monitoring_attrs', + 'intervals') + + def nr_regions_range_sysfs_dir(self): + return os.path.join(self.context.sysfs_dir(), 'monitoring_attrs', + 'nr_regions') + + def stage(self): + err = write_file(os.path.join(self.interval_sysfs_dir(), 'sample_us'), + self.sample_us) + if err != None: + return err + err = write_file(os.path.join(self.interval_sysfs_dir(), 'aggr_us'), + self.aggr_us) + if err != None: + return err + err = write_file(os.path.join(self.interval_sysfs_dir(), 'update_us'), + self.update_us) + if err != None: + return err + + err = write_file( + os.path.join(self.nr_regions_range_sysfs_dir(), 'min'), + self.min_nr_regions) + if err != None: + return err + + err = write_file( + os.path.join(self.nr_regions_range_sysfs_dir(), 'max'), + self.max_nr_regions) + if err != None: + return err + class DamonCtx: ops = None monitoring_attrs = None @@ -79,6 +210,46 @@ class DamonCtx: scheme.idx = idx scheme.context = self + def sysfs_dir(self): + return os.path.join(self.kdamond.sysfs_dir(), 'contexts', + '%d' % self.idx) + + def stage(self): + err = write_file( + os.path.join(self.sysfs_dir(), 'operations'), self.ops) + if err != None: + return err + err = self.monitoring_attrs.stage() + if err != None: + return err + + nr_targets_file = os.path.join( + self.sysfs_dir(), 'targets', 'nr_targets') + content, err = read_file(nr_targets_file) + if err != None: + return err + if int(content) != len(self.targets): + err = write_file(nr_targets_file, '%d' % len(self.targets)) + if err != None: + return err + for target in self.targets: + err = target.stage() + if err != None: + return err + + nr_schemes_file = os.path.join( + self.sysfs_dir(), 'schemes', 'nr_schemes') + content, err = read_file(nr_schemes_file) + if int(content) != len(self.schemes): + err = write_file(nr_schemes_file, '%d' % len(self.schemes)) + if err != None: + return err + for scheme in self.schemes: + err = scheme.stage() + if err != None: + return err + return None + class Kdamond: state = None pid = None @@ -92,6 +263,27 @@ class Kdamond: context.idx = idx context.kdamond = self + def sysfs_dir(self): + return os.path.join(self.kdamonds.sysfs_dir(), '%d' % self.idx) + + def start(self): + nr_contexts_file = os.path.join(self.sysfs_dir(), + 'contexts', 'nr_contexts') + content, err = read_file(nr_contexts_file) + if err != None: + return err + if int(content) != len(self.contexts): + err = write_file(nr_contexts_file, '%d' % len(self.contexts)) + if err != None: + return err + + for context in self.contexts: + err = context.stage() + if err != None: + return err + err = write_file(os.path.join(self.sysfs_dir(), 'state'), 'on') + return err + class Kdamonds: kdamonds = [] @@ -100,3 +292,17 @@ class Kdamonds: for idx, kdamond in enumerate(self.kdamonds): kdamond.idx = idx kdamond.kdamonds = self + + def sysfs_dir(self): + return os.path.join(sysfs_root, 'kdamonds') + + def start(self): + err = write_file(os.path.join(self.sysfs_dir(), 'nr_kdamonds'), + '%s' % len(self.kdamonds)) + if err != None: + return err + for kdamond in self.kdamonds: + err = kdamond.start() + if err != None: + return err + return None From patchwork Tue Dec 12 19:12:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13489785 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 1ED42C4332F for ; Tue, 12 Dec 2023 19:12:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1799C6B0337; Tue, 12 Dec 2023 14:12:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F35A96B0339; Tue, 12 Dec 2023 14:12:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D614A6B033A; Tue, 12 Dec 2023 14:12:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id B3A1C6B0337 for ; Tue, 12 Dec 2023 14:12:19 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 87A0D160903 for ; Tue, 12 Dec 2023 19:12:19 +0000 (UTC) X-FDA: 81559111998.09.938C504 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf07.hostedemail.com (Postfix) with ESMTP id DEA4240012 for ; Tue, 12 Dec 2023 19:12:17 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=rwumpu7p; spf=pass (imf07.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702408337; 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=gRWLBAxz+7SsKpxgT28rVVWe7oCM8SAKhqIhIhMn5oU=; b=ASfE47AeOQVBeZZ141nN98ixOqlPCJ3cjfATl1pcjnwqX3O20zTED5GdfcDOIWVzAxyHfj wTXSi/iU/CDH8BjPC61DAxzIk0wbxKnNb6q4ZmqMCPVbbHnHzL/Y7oBM5qkhk/w4406Km/ Ejk/9uE6sZpKz850HzYNeGX5uOqR3Wo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702408337; a=rsa-sha256; cv=none; b=7DcIgWWL4UxPTO1lDG45u5IacK8d0r9U6yKrCaUWP6xdUw+jwCszSk7pp6hK6maogBpbb/ V43tbAjZ824dTJJvbDWJLhnIDOCVkx0bdcCL4AKdA4mC5OZA1qdi4BdzKjKxQZta3l942v 2+hix8gEJHncklR9UKtwwYPYj7iGQts= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=rwumpu7p; spf=pass (imf07.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 1012C60F5A; Tue, 12 Dec 2023 19:12:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48521C433C9; Tue, 12 Dec 2023 19:12:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702408336; bh=KLuaGh8EwddqX7r2J8YW9fbCxq8vkVUE+TA3xcNvnkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rwumpu7pqmpvnDomf+Hqsnh0almVLDis4X1s3RgGsNDBz1ZNxaQgGZbkGcHD2x/om J9NHY7Nzm0oEjemCVbKBPT7iOAW3johkbPXm490MuyodKOhYIuS5rsfTARZVtZU1E5 O0kOzVSh0a+F09ETl+b3CSjG7q+9sd3xzsgXymt5ebJVzKRQJFLuL/Kao+V7ppEse+ eg2aB2v3Z5oWVnQDpYZqszt1gRobfnX8MahYjx5ZdRL1mJJw+IPIoRr07D4ilPKjIV Bft87B19yWmf4YZud7k7g/adUKpw/LAVDb87F0MOmJoi+ySJPPFGcHbGB5tIFddkKL TRJHV+KZqehZQ== 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 3/5] selftests/damon/_damon_sysfs: implement updat_schemes_tried_bytes command Date: Tue, 12 Dec 2023 19:12:04 +0000 Message-Id: <20231212191206.52917-4-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-Stat-Signature: 6a6cqsppioaca5kw5omf7i54gpsu4hpi X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: DEA4240012 X-Rspam-User: X-HE-Tag: 1702408337-837993 X-HE-Meta: U2FsdGVkX1+2Y+2Kg2hAhHZApvur80CpYVD/gqwqdkQvXMuCBMucC2WaUic0Bb4A2D4bXgJgQIKbcLdFL7BEOtwDyh0d2FKm5ChcTdAtTwK1dBH5oZLXeJTBjMqZylm7vOaXpRwVGgrcrQ9l7aRx5NLBOYYR4kHGu4FAMsxI2QmDGsK3nzkatsV6eVQJl6UV9YRgpNZCvFCEfdmaHuQxUN4BRUqB7aJG2ZxY4TmxhjnCBWAgOOukZ0MGRDX721Sqy1WrXKlew+rmCmRv4OOZOdlZhNHDavIufZ44LJoHywpUOMJDgov6mzLf8LDKkK7MBaA2xj1HspAvqmDura/DeXvJyF2CHTZajmuJxY1XDbIFybQmSZm52uisHzd7bZGgqE4YurFvd1zBcoI4UYY/Z4bgFINuvKB2tf/n3MRQ9K02tFv6CgFe3nDQKymT+pMi0kJhQRyHeYiXuliNmNvsFjaUbKJIIcxBjJN6Jj0d/rJUcqP9PUqZyxECIC2sMitHh5Qx49V6wLlz0whrc0LjG6YMXNCkwsMqM+NnzqfL3Ou/lhqjOqWUDvboylRmYOWeMAIecJBOFDXKH8VAv2S+GumhfVc5GwA3ah5I+HSqWj3IEf+uz+DIg4SrI5zb8JggOotgqi6NCuSNvrKRfBtd/2rOIx6bGXfPHLNG8CuWIgQIlmJSGyScJRWdsqfF7ataKuSNQSYiCt8Hd3QU/Su/N9gQv6klvopItSOGrNE8Kd2mmQjlFPsDrDvuwV+99nUFglgmP4CETPthHUHNDZTSrl0uYJjGu67MUN8ngvvBIV2ZGzTb8Lgav480EFAZu5DwuwAiaDRMsOmxEc1tenjz1D94l2xheKHZA62tMfZ7jbD9kwUVjme7TxiCWSReBfU4lDLtnfYIrGMgzhHZjTe4RbFRl5xIPsJ29kPPLhf+70VHVRTSvfJmxNn0IAXJFutHVbQ4nHa0+IOqhw42fnK zJIJh2QG mTzRFlLAeIHyZuxs7Af49aDNK7NrAnu0iVbHs9Tr8DKP5VeReCHrNHwAKFpsY7l28y4alJQGFckV4BN2BnvJtZjpR18BsRuMMmNAl21VMnI/WrBAGPhBzXBts+btc9rLo1B+Zrg2yd8IMKxxaGrfwwQSI4SXJrPZlut0kn+akiv2bmq4aggyimUzjkdqhd5GgKuloAHR+lobft3D+htMc6QH+HzufWrWhPcvh2KzRsggAWq5KE2B2Bv6eZSQNmYq8K+fKXOT04iNuCgyZScdZ4y3Rdw/4yYx0Lk6Y 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: Implement update_schemes_tried_bytes command of DAMON sysfs interface in _damon_sysfs.py. It is not only making the update, but also read the updated value from the sysfs interface and store it in the Kdamond python objects so that the user of the module can easily get the value. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/_damon_sysfs.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tools/testing/selftests/damon/_damon_sysfs.py b/tools/testing/selftests/damon/_damon_sysfs.py index 6b99f87a5f1e..e98cf4b6a4b7 100644 --- a/tools/testing/selftests/damon/_damon_sysfs.py +++ b/tools/testing/selftests/damon/_damon_sysfs.py @@ -76,6 +76,7 @@ class Damos: # todo: Support quotas, watermarks, stats, tried_regions idx = None context = None + tried_bytes = None def __init__(self, action='stat', access_pattern=DamosAccessPattern()): self.action = action @@ -284,6 +285,19 @@ class Kdamond: err = write_file(os.path.join(self.sysfs_dir(), 'state'), 'on') return err + def update_schemes_tried_bytes(self): + err = write_file(os.path.join(self.sysfs_dir(), 'state'), + 'update_schemes_tried_bytes') + if err != None: + return err + for context in self.contexts: + for scheme in context.schemes: + content, err = read_file(os.path.join(scheme.sysfs_dir(), + 'tried_regions', 'total_bytes')) + if err != None: + return err + scheme.tried_bytes = int(content) + class Kdamonds: kdamonds = [] 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