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 From patchwork Tue Dec 12 19:48:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13489826 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 6D2DEC4332F for ; Tue, 12 Dec 2023 19:48:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BF9096B0353; Tue, 12 Dec 2023 14:48:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AEF0A6B0358; 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 874BE6B0356; Tue, 12 Dec 2023 14:48:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 6BD416B0355 for ; Tue, 12 Dec 2023 14:48:28 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 40304140ABB for ; Tue, 12 Dec 2023 19:48:28 +0000 (UTC) X-FDA: 81559203096.05.9C22DD2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf20.hostedemail.com (Postfix) with ESMTP id 6B7EC1C001E for ; Tue, 12 Dec 2023 19:48:26 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HA5XbunG; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf20.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=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=Llj595fCp/6fkqvOsmjH1Ip3cww+RZOnknJ+I9nFpd4=; b=kHbKUSJqmibqfJu4/w/ikjfCdAOnGeEndM1ZUzgmrdISmjMMz6MJkWw2fiQkf19Ojd5/y1 r+Ipth4YC1j/c/B9nbEuXNo+N2zA4D3NhWVyJ1Jz7Dlk9qK2P86aGBLf94+ufgKrKyMawB B0DdizRXRQwx/srI1DZAjajOmhGgSqU= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HA5XbunG; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf20.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=1702410506; a=rsa-sha256; cv=none; b=WcBXyUJ/WvhTglq2JtV7VHdrtKXzNQOduw+vHe1BT4l3ZhGamYz4hGWCiCm6jmt1XzOGFN bBdFO/EfwD8XyXnPiZUqTn1nwmNVFiJ6KWdDZpBsOmTMh1v9dR+m82UcbIJwhciuyk1HBh jdz11HFxOtbTWSpdZVVZAb+iNpobN5g= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id A6A5161994; Tue, 12 Dec 2023 19:48:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9C69C433C8; Tue, 12 Dec 2023 19:48:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702410505; bh=DR2Fa3ovjeZyoem+oDl1suN899iJhJUC8UTSzsABCII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HA5XbunGmbXfx0Q2PBWZIxDGcBV5Dgvd4kTY6CbduAGZC+9muRTppO4PFe28T/5i+ CmRI1fkjAnKa1Nco2U18Ye7denvai3M3JgEXMpTQ3nSRWFQ2mPdOSy6zaHt41Skbdc 4BYfTX6VlFveLW+mcLa0DSfgORdTEKPz/j8cu8i5YSkiTKb0pcvSHH4Vkljr7mXNZi OKDjuTBDwVxNJBELhM4NX8g+i9EnR9Zv8JYdqUkmasictn2ECU353ZPspXk14NWbju 3lSWV3+4BKRlFdFjrSUVWG9gELYl9bKdP/KfdlLYVS6k1lVFspUt8MPDSgcv8aPZPC 1mpjLFnRNMFOA== 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 2/5] selftests/damon/_damon_sysfs: implement kdamonds start function Date: Tue, 12 Dec 2023 19:48:07 +0000 Message-Id: <20231212194810.54457-3-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-Queue-Id: 6B7EC1C001E X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: nh1z9usw4rrdzebe49ydkt3nd9d9wp1k X-HE-Tag: 1702410506-463279 X-HE-Meta: U2FsdGVkX1+nZxpyWlc1N6geljODBw3Tepg+9CphyFq3xUiRn4H+xoiqzt/Fc68tYcfiIKDv8/iR/4RuQypUeOeaz+nZ8qeyF1SIfH00RCKkhxliRabbUD8iFS8xO2elWI1fUun2QlpksQwrU/+LkrQVdoPMSQSfBVki3hGILHSv5uPTfpeaThNmy5+btKWf6RSse1Uo3RwGsA2OaPjJLRyQkS01spxKCaW0CywO5r8LsYGAjVFQOl+EtcVjPuiBbFM02/m3WVzlYEI29KQYdKDK3haCIJp0DVJLHBeaZsTZ3MLTKlgiP2F+I1gR+7RLJEbEVbtIvssgu6ZBnCj/JntpaD+gX4Hcws8XzKOybhhDoDfs2YaSLN2dgIsqt7FCB8HZB+ApfbyyK97rPZBxK0OUSttW8TVQrhfHgRL4TUBVQmjF9u77PsybESmaMHwnQLyK+x7UGbxiGrNSPsEZlkDqS+RpWf3Pb3BIG66c6afqYkpi5zjAlH1bapjw1DnkUs3UeFz/u2YkAzTNLnWquyRlvuO7+eyvyVKDWkmBVwEc7dpif6P7w5h763gZRw7KbY8LrwTvwiJIMJQ++Z8VGofsI7xRLydDgh8MplsPDwUIjNpohyGGyElk7F9J+16MPDq/jlGdIAnwTj5nqarkaSsbAmsr4kAJqknTLINLR/GZUM/6gfU81rY3zlhIij2mU62FcvXTADHE6uausvEf9HV6b9BoZXjwqQmrwg1u+TWaF0b6C1deuJol4I727j5PzxATFtzyCaSE9aYJcuw1IRaPwRKeNbFXsUKPL0Fb3SehY1HMW4SLXzgJMqiw4JcbcZQOQ2pb5ssmTAwYHvBdcVm3iHqAdcVIg2g/+hXqA7HNx+0HEfKtvT6h3QJEJm0YIghSYknbWckrWGPnuXChNIPEtzD01LmzxbNWKxVtMXyBbyMftz4rhv+EJtjAhEwoE9c2aJ7ZVpDTbl4v1et CTPunT4k hFt++/ugHgktPWSmow96sYxkt3ppzaK/gKH1pTjh8i9tgDLbgRfLcgGEhR2Jqi4i7AKzedvZ0j0s+Es0QbZD06CDo8C9Dt+K+fd9NKXAQZVE95eanw4xpLExlberLaQDbDEh3OFL9Yd2x2Mp0NgXRfXBNNiS5SOO7ezYxFWk4SrzhRymOXA0nc5iAGC126r5RLIRoCurofN95DJ8GBoY3lmhieSJkIC+ypt/Iuh+CirvFLghYLp41FPmZXPiBfjP3/szEvuI5FCeWPfviPQi5MvKLlcitNMjcby/2 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:48:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13489827 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 DF15AC4167D for ; Tue, 12 Dec 2023 19:48:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 34C086B0358; Tue, 12 Dec 2023 14:48:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2CF836B0359; Tue, 12 Dec 2023 14:48:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 170F56B035A; Tue, 12 Dec 2023 14:48:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id F2DCA6B0358 for ; Tue, 12 Dec 2023 14:48:29 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CE8D51C12CB for ; Tue, 12 Dec 2023 19:48:29 +0000 (UTC) X-FDA: 81559203138.16.0802602 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf27.hostedemail.com (Postfix) with ESMTP id 2FBD940005 for ; Tue, 12 Dec 2023 19:48:27 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Zp604m9f; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf27.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=1702410508; 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=QuD5Lj5B/Vt0wxh8dAGum/6mAE1lfinwFDN/yBtOIpRmsV2j8GzFfM97f4rmEUGeg6iZvB r4N4gsQFesvCB8M3LCBK8EvK4aAcRz3PDVwAXKgX3AilnKBz9iSZTO/tCRCmcTT3IyMeLZ n91B70eYwgEZQ/VDLC7AWC/aIgNQ21w= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Zp604m9f; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf27.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=1702410508; a=rsa-sha256; cv=none; b=y2MUO6QNzwWjDXeMfUPO7u0tqS2ORIyIiCvCSCwlCnws68As5OlkEDmgiHtpW3G9fpdn+8 CPe179vyAGn4+yvonH8YnYgUMpaLjGKLPQQd6L2SgHXNkMw1KqtcFRgWScGNVBOOdUVK3c jchVlOdy5ffStREocamF9wKfW+tId7U= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 5ABC461300; Tue, 12 Dec 2023 19:48:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E92EC433C7; Tue, 12 Dec 2023 19:48:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702410507; bh=KLuaGh8EwddqX7r2J8YW9fbCxq8vkVUE+TA3xcNvnkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zp604m9ftO6CMnttej87Sh6VqLpo04BjspyTqtAXT+YNv+UIX/RoNfTg/V8Y4/+v7 7pXqEGOTc5Y6XxCRWrKt+/e3xzZGonBbtqWSI+WT0SWjfaWW2ZMItPC1+QK7sec6wv ij4Ozs5y4003odbvfBk1OpZbHUCDdHbapSaOe1TsKjrYpY0nfNqeDQ0dcJskywxToH jq83xtlZhvR3wpX4cTV0/8CsLQdBB7OZ37T0Su6s1GlBmDPBUibW7/EMVvdHNPt5Sx EQM2SVuASgPb4Vdu0AdQUPE4ZP/4x8RCpZC7vkdjuv108qv1TQtoo2Be1g9CKCsZMt 2zScFDV0Pw8AA== 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 3/5] selftests/damon/_damon_sysfs: implement updat_schemes_tried_bytes command Date: Tue, 12 Dec 2023 19:48:08 +0000 Message-Id: <20231212194810.54457-4-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-Queue-Id: 2FBD940005 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 6iu1m6tpy9q1femj3xqyks87q3zg6qrq X-HE-Tag: 1702410507-909463 X-HE-Meta: U2FsdGVkX1/yu0dW8+w6tqcL8yEqjaMWZetB8hCXKUBehSmruCY6Qx7vpZIjkPFWXpUSGwOPO1VUNllciqHj7oAq8tbLjLF0hZJWNyyTrAEaBXByjbmDvnm3vmMIwQ3wPRniKnDNfeBlkD9uD9Z+KjTqXb7poJ0znmv4ScZEdK4IIS5/uuJ45IODrhxggST7us0feyK7rO5ToyFyP2CCzVsF5s3ku5RZcUtavaWJ0V/XOAZnKLy282aoUwIQ2YeILUppSIjJJdsamphd26RN0etYUflSXnwt5AfwzuzDmAKuC52ivULxgRVDUNRULsnVhdoaP5ZlTGRsluD0tedh0K6dnz9dUPbMLkAXB4QpPr/+bKD6QkbHr3Yh7Mgb8b3GmuKHs6oGaoLAavE/PshEMeOUuEYZmoZSyNCqbR30xfukjDhiw/9uwCtgSzjJjOxtGaSoaONcVBY/DQj2F1TdSHcis8pFASLT+XK8rmz5jAk2B0RbdpC0NvPRw/+NcO0BJJafiQlTDtN1aUqAWdpGIa0bMwOC1UNwLES/fRrYP0cfeb/6BsmqymgDTnxf3wJz+/mp+o0rCXxEkNTvbqJib9VxiZQYbVJeXLfeizGOkt9vrGYcoc3u86cswDgPD+G/hy6yzn9Jvflsht6X3Y2olQbZbSVcLerYHkFczN7b2qQRM5tRgqjpHte3CG3xq+88D71iLpl5De4lDNvD0RLFr9gYr8MPUrmTelQihOIMdAltPc/7ccpRjT2qr9DdDvO0OTfh6gQnvSCFM1W8dfMtbYonnmfDU1sEqGZYa2M8xHzIo5V7J4dIvu4TlBQ3/zd+AEn9rmAB8kVcoo7q2y7pObzAUIJyYP3dUd0mSJ+/2/DEPSKKpPRnATQefB9120t1P2jxFmlAABaQnXEnDAg0RmttMUYfTlmthhNIJja2zChxQlHWPoQrax1398XuirXXwZQKDXFcQKB0an3clQ7 0tuXbKVA Kt8HK+F63GhtWWezy7SOuXZ6aKmVCOeY2ez7AC7VrAtyjeIt0dNdaRhNvkEMXG2ScrOXN5llPEVMJSeLXONi5zIMCNBFhP8uVsTO6MAc7lcs0LNZtpqr1zjwiaq4z9FEkYCaWJeV8PUBTcWrQiM+eQlXwUW9mFV72qjw4W6ozcZA3HVnbXq8QCSBSisRXuWhUZ7duKh41f7UwjK5CN2QoyS6C8CDRlAzrTtII6TsPpHg7QFtBJZQeCnLNWeHTCcsb45o4r7hcGU0Z0u9P3W8Lx3N9mtycZ49Gsdtl 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: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