From patchwork Tue Dec 12 19:48:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13489825 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 10900C4167D for ; Tue, 12 Dec 2023 19:48:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9620B6B0355; Tue, 12 Dec 2023 14:48:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8EA8E6B0353; Tue, 12 Dec 2023 14:48:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7654C6B0357; Tue, 12 Dec 2023 14:48:28 -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 5AA386B0353 for ; Tue, 12 Dec 2023 14:48:28 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3B0501603E6 for ; Tue, 12 Dec 2023 19:48:28 +0000 (UTC) X-FDA: 81559203096.01.3F2B1E1 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf24.hostedemail.com (Postfix) with ESMTP id 634C6180026 for ; Tue, 12 Dec 2023 19:48:26 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Obwd6KSB; spf=pass (imf24.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702410506; a=rsa-sha256; cv=none; b=eVK+RYZPqouvWp6RfRUmrDx4vFh6K57WOAM2oUg2zRt4jkhWFAqxmlJEywDVzZUyV7sXlF Us8+MaES2TKx8xozbmHnSo3MmCQK2fL1QJAG/IXVr7SuszwwTyAaN7QWuk1iaUl7n9jBJf hcLY8pG+79Y2THMx7YJnstmgedo6yxg= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Obwd6KSB; spf=pass (imf24.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 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=1702410506; 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=y1+ZcF8/1lrbRXLyD6iYnEhFcmRKn2Zy3MHl0l3eX9ZWdPkg/Zc51rLcPC7qY/uUWb9A9Q dc7tRAe6+TTZPhBVkC1TFPobG0JgcBjE3GkBenpSnB6rkYxpuK4q4iJe2foCksRnjPCCGH gHdC+4NOKgPFqyP7/bUXwTDuDCs/Ruk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id 900BBB818A0; Tue, 12 Dec 2023 19:48:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6006BC433C9; Tue, 12 Dec 2023 19:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702410503; bh=GHi4Mu0bQn8zyIS9XnsaUAW8ixexoLEYfp8Ut/tF7Co=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Obwd6KSBu7yEpmBw/dBCKi3p5kDvWh9E+GlTXOe0rl2kvSjjSyg80KsX//CL5IOT+ glZi5v6QxLvROXt0kCa/0sna8hC8Hjl4upM6UDnOraWp7Bthk7bNDEwLiu09klIOGj pvkV+86iSsOYkidaGs1abZHfna5A7LCWqpBVhfoX81jSOpdQs6E81jIsxe3Hje7xPy Nz6JBPTGqwERFlgceforF/dUW6v8Wt3P8SXgw3KtApsiFtzI2UWugnaHDO9kizcRGk MT4jyMcs/ir+RygcCiKXB+gJN0mkYzZa2/mf7wsDMhQsU4IsIPXzTf8XxpEPdUxGT1 ggO4qcGogav5w== 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 1/5] selftests/damon: implement a python module for test-purpose DAMON sysfs controls Date: Tue, 12 Dec 2023 19:48:06 +0000 Message-Id: <20231212194810.54457-2-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-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 634C6180026 X-Stat-Signature: fousdhn9agcw9m3b4idmqz6zutca1ipd X-Rspam-User: X-HE-Tag: 1702410506-306673 X-HE-Meta: U2FsdGVkX1/hAgBZu80MrPJVnHHtlNrWEBHke9aTR0A136SW3/qQn3gXqpu0waw0fDCkiZrgiLOVTCqgo4QVsH5eWo5IFQYYa3R2AnLl9DFTtTnAbuObCkclBb3Pgkb04nevyDCajPU5V7qDUQ4IHNrXnVGBuBch1KXwuaTxPUoIj6yv6Te9yn18EkabNI9Tu4+krapIkYonj4byLomopN8SF0etwWlKfIIF68fkNkThcvg5/XNOz8wY2Bs0/JsVpQAU+0565pXQZp3jBI+vXamaBqMpz7k3LGdSDxBtYnke6gPbrd9fUphOlaZRwQGE9Y6yQob8uMksw4qvnj3wXW9XRtwGrbCloFqTEvSosUrVKX/zn+9Sl0Z2cfnO98/VntH3Ek5g1lrEfkQJ4oMcrpPE8IZwrrRD8nR+2GEiP/mzfOg2u2lvTvjPUuL2MpmGbgkafOsErhfnylMgPrkU/lNnthG16ADVd5JY5YHGEurktPe1RR+a7K1wY7wNurFskaHV34hIQa4CyBAODve2AL+LibKKFpoAQkebk+VWvuenUjKzXz5YtKHIIVmEZfHKiHCNjMq64Q44SXDQHGRJ7Xqi7ZPARm1BKDKBHvJxI6ORngQX/235zNxJIhJnU5ptxvHfV7vLhL7ZVH0yrjx3SZzXxJA/6k5r1jqxPFDfA/+em2hDSmM1TcPj8ejIwK6MowhnCfF4xUrca8dFu8U2OAFEwobyvC/kwJKvtr/PyecUbk9f4fNvcSTXYPi6B5+UmDbfXaMHN9DUIj4PWYfcwoxl09C/2zGJEU9XUq7+auNRQSHS49Bm3gEOaOBvM+tiNbwxtRnZv79L3bbmBgm3fNI/OW8ZcWG7kb5uQI05PRNmCZNoDWhJW3cIVK7OoCPLh52MZJos11nkbUQYHCwZkZlfkczSu8FNxjxux2/x9ZR/iQq6qGPI4oNgh8+9egvVAO/QXYlo7/7jqxrs8jl UY0UKWPV 4/MOxF7Yu/BSEl7lFwALLuMYybcqYvmRXi+vAAFFkLILN3VjiJrwKtuOPl60QVELUdx9kPrpg4XiXtTz3xknMwsd/MGdK8Ugkfpre1S5GodCsnfJOvzfGBOecWijIZAlBpjR9nJre6tMGvoZ8O+3WQvbqt4hzBqWEtdvScLSVN1MbzcjGRST+GAfHU6jaxek9TV0BKH5q/5FnNUo6V0ezwhgr+ME3DCNw8NNFDNX9bOjgivE= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000004, 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