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