From patchwork Wed Feb 7 20:31:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13549057 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 EC238C4828D for ; Wed, 7 Feb 2024 20:32:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 45FC36B0085; Wed, 7 Feb 2024 15:31:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A8056B008A; Wed, 7 Feb 2024 15:31:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 00F306B0088; Wed, 7 Feb 2024 15:31:50 -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 D50FE6B0087 for ; Wed, 7 Feb 2024 15:31:50 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A9C9E1A0924 for ; Wed, 7 Feb 2024 20:31:50 +0000 (UTC) X-FDA: 81766153980.29.2BD358F Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf28.hostedemail.com (Postfix) with ESMTP id 44830C001F for ; Wed, 7 Feb 2024 20:31:46 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lx8mnNCB; spf=pass (imf28.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=1707337908; 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=e1UvP10+60uT60vfwuQyHfpn7s5IoP2FL/alemxKsK4=; b=Uiz/MXoE/tee0U8Uf/mn1wZc+jo2Y4ovMlUoQfNlY+jFKmygswpwhfDhlaTKCLyj20YVZG QzTmjG6Htrt+xNvqGzt1xS2tOGLWK4jfAkj7bKdHPXTgp3TqY2RMbvIqDzjBpYDWTDcfql Pwt/1D8+U4WGLUWB7lR/GxzPwLscAEM= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lx8mnNCB; spf=pass (imf28.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707337908; a=rsa-sha256; cv=none; b=KxO6/xtOYY7ff4rA7lDDq4rKLSiRp7rW2D64U4i8VD2jBo8Cx0n4vpKHeLG2wV7j3iWJwf Tut5mNrsEF/2BQ847AdlNOR4zyo59gC1t+or1L46uZ7rpCNBKkT9Ksm4QC1E0uLlF5BcSa lCCUDjXz+ZXpujGX7fdZzb7MHFa/ajY= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 76477CE1AFA; Wed, 7 Feb 2024 20:31:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27297C43390; Wed, 7 Feb 2024 20:31:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707337901; bh=JQERS+AD7eJcXPmEIi+Gcjav4/4TJSgTRdHhSGiTeC0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lx8mnNCB3FWWVgO2+jRkTgucZGTLeSzoBIZ/EFuBxNFxGuPQ0D8MFrtTw7iwrE1Na aFQEjvUUK4Yev4Dy6G++TsGO2kIx4pcqN7D3BLsUKIALU3zTZalx1xNnZcvJZPrvsF H8gT8OKhTA4A5tPW6EPXK+ZEpjk546ZmS104vhzh4148PSKRj4FOzL6qNZZDwX/Vyh kMtuD1aZQm/PWZwzbxHibyvmi6bSLIQiPQhoQniGkMI61KXBripkvkHUukfFQGYqvm AlXLfX0IgWrj5f4KRCZMdu1nEmvG5U82kPY3ZAZt+zPUu8QkR+FMe1jcOaIyNuRbYm +QowLnrkH/NMQ== 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/8] selftests/damon/_damon_sysfs: support DAMOS quota Date: Wed, 7 Feb 2024 12:31:27 -0800 Message-Id: <20240207203134.69976-2-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240207203134.69976-1-sj@kernel.org> References: <20240207203134.69976-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 44830C001F X-Rspam-User: X-Stat-Signature: 8a1eky3cg9m88tpm7gar9t5is5quk4th X-Rspamd-Server: rspam01 X-HE-Tag: 1707337906-852717 X-HE-Meta: U2FsdGVkX19W7dGh7UBpSJoUPSmuhtksui2vdfDnv/9VBedoplXCFIG0juUePfa6hdCwktDssOzhMGFado90t353eYWcR89RrdnPrCuf8uhhvQEmvHQPMK1KNTm6UsUaVdHsxrqDUYCcujQQTJ9NYJn7YEA9XKyMgRBNHQNo+QEWeneiASkWj/Teh2TscQNADyIZ1OdlV8ATSDmBlvswcRTn5HAJhEdt9KHHq78EIA2aSvQcE9e+y0qIxKoa6jWyK3yc5q8Kkk3qnyRyHrjwHeGUQ0xrQLHXNrfLQGAn0yMSh4qftZHYSYbXqSJCU4LiSBrJ0eEkGkbxQ1NkW4HY6qaPijdGsfnS3Ox7z90HlAzF9zsw91UsjIbmY79Ed2eMP+IV8LvC24IpnasxNZbUg9UyoychvhyVeGAOjhrWPRHtYKYLhBgvVDQGd0OTf/MckMcG8iqhzeIMUP31sciw7dkN/iUZxTHjDcPMEocJ9Q8u7Al/e3fFonaI9gex4IDpQBsLLH+uxsu8BNogXrRWR3N2ZeQmJROQm8VeAmZtdYB1oLBkeZCLdta6Gy72T5grp712/q66+CY21+dfLFfnqusEL6uWOOrHEYC9xPS9RGV0mEm7Lrd9cBIG8tWKnfggzlfVCleLHfvGJP2WJ2vOSj6br4C4laBc1fYKFS6lxvtXSbg8+i0mESHfq17mH7lEOhVN9V0cPspzBi/QW8c3p6dBszsx6PyTlYe52n3RSbu8tpsh7ODVHnJqe4A36T6Y7+YDkZWNvIfbnvhOW5QHfC2TdPUXO26/sZvqm+yqqp1p158/Nl+FjidQe2MItDEYgDiQdG3yIbVBfFt794co3x26v4IVmjItX9v4MzDS9fEzEy6PG4PoDbF1ELwF74thK1tWaCVaX/atU3pJnyJql+1H0+ahaVmwf62w+TJT6Cpv6YKC0WXt06/sacINUmXSYJzhFF1jUuS7alAEb6F ks2DXcGT hybmMjTJwjj5fsAYmYbGPyZbuZAMOAiORh2QHFbDDxyszGcFwjrc5OzLFDqlr6wVQUV3+KjpzFMVQT81GTpCvP6ol/YJVJmtDAFOB+NfK9KEisOQVY2T8mG/9Wyf/vi4FvhxWUa6Fo6wsfSIoOUZvLf1c9NJrZdjQ6LM0p72Sjjlq0Cme3CZq4dKngP3YVPMinkARxh4mM4IXtsyrqy+VlS4wbN1jqDLa3d8oYbkzD7vGEabw26hvuiPTLAiWCI9nk3ip32jp2qt4m0j71mPEpb1d+A== 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: Update the test-purpose DAMON sysfs control Python module to support DAMOS quota. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/_damon_sysfs.py | 42 +++++++++++++++---- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/damon/_damon_sysfs.py b/tools/testing/selftests/damon/_damon_sysfs.py index e98cf4b6a4b7..b4f6e385c564 100644 --- a/tools/testing/selftests/damon/_damon_sysfs.py +++ b/tools/testing/selftests/damon/_damon_sysfs.py @@ -70,18 +70,48 @@ class DamosAccessPattern: if err != None: return err +class DamosQuota: + sz = None # size quota, in bytes + ms = None # time quota + reset_interval_ms = None # quota reset interval + scheme = None # owner scheme + + def __init__(self, sz=0, ms=0, reset_interval_ms=0): + self.sz = sz + self.ms = ms + self.reset_interval_ms = reset_interval_ms + + def sysfs_dir(self): + return os.path.join(self.scheme.sysfs_dir(), 'quotas') + + def stage(self): + err = write_file(os.path.join(self.sysfs_dir(), 'bytes'), self.sz) + if err != None: + return err + err = write_file(os.path.join(self.sysfs_dir(), 'ms'), self.ms) + if err != None: + return err + err = write_file(os.path.join(self.sysfs_dir(), 'reset_interval_ms'), + self.reset_interval_ms) + if err != None: + return err + class Damos: action = None access_pattern = None - # todo: Support quotas, watermarks, stats, tried_regions + quota = None + # todo: Support watermarks, stats, tried_regions idx = None context = None tried_bytes = None - def __init__(self, action='stat', access_pattern=DamosAccessPattern()): + def __init__(self, action='stat', access_pattern=DamosAccessPattern(), + quota=DamosQuota()): self.action = action self.access_pattern = access_pattern self.access_pattern.scheme = self + self.quota = quota + self.quota.scheme = self def sysfs_dir(self): return os.path.join( @@ -94,13 +124,7 @@ class Damos: 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') + err = self.quota.stage() if err != None: return err