From patchwork Tue Jun 25 18:05:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13711787 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 7A5CDC2BBCA for ; Tue, 25 Jun 2024 18:05:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 12F066B009A; Tue, 25 Jun 2024 14:05:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0DD976B009B; Tue, 25 Jun 2024 14:05:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC0416B009C; Tue, 25 Jun 2024 14:05:48 -0400 (EDT) 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 D21F16B009A for ; Tue, 25 Jun 2024 14:05:48 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 8D08340466 for ; Tue, 25 Jun 2024 18:05:48 +0000 (UTC) X-FDA: 82270189176.28.0A67FA2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id D4A334002A for ; Tue, 25 Jun 2024 18:05:46 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=owYguYF0; spf=pass (imf11.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=1719338735; 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=3pO6xUwej+8deW8c5rOcwx8Ubgzhrx8CE82GCD55xXc=; b=xCufeywG7/SZzeApAR2HqQB+bOx2Q/+T+S+h9jh4g8CXTpcHdA9PtVU+xzHNohohBHhctl k01ymA4MLkUJ3JmMDAF91go+Y7sf8qlW4UdKgOTxiZilOF0LTKtzKW/BIJ9ItSPCKYPIqt /vbCe31AUlHs8u5ny7MDN7XU9F6NFb0= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=owYguYF0; spf=pass (imf11.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719338735; a=rsa-sha256; cv=none; b=SThkh5WPqYvi9gJ0ZZNEKVi8NmmHeMpPmMMqv6Thi0bw1EiC1eY8ihPm2pmAhDXTQMxoUH IFa9JtGFEBzwr8vxm89vMM9WfQOc+nB7jn1KxFJiq6H6vb2NiK5evwefZT4ZiUM3EoNjc0 TnxtJn6fw8Z9EQM0bMCB3WmAlEA7sN8= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D547C616D8; Tue, 25 Jun 2024 18:05:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20FCAC4AF11; Tue, 25 Jun 2024 18:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719338745; bh=IqlT1IPKcASfwAbySeLSD/8umJwtipY7yMwxEMFH+lY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=owYguYF08Cx4JYwOY6o1g0owoG2dsbNcaU/uOyKCAB27ayZjRretUhozMpE1EHQlu Aj/K7T8lVNM7nt8K2aJagUURVKGF67WC2KKzKvP+ndwQ3nlbi/8hIhtH4xJJwEwWMC ThpMW7G8krb7u9VhvABkwUTDXPcgKXz2DBHuNhgWEaVQl394tetaG8Ms9gUq5MH2sS aS+Rv3BrsQ4PHUfZhg9IkyG8wZvNHeeLcdD4K1a5CBmgnPIjFRZKzgHV9xNgresdvb aFOt+PLj2NZTMUdfPsJUIpGXnhZePKEGbStW8i8bxkRVLIiz5q1uhRGX2tOE6rOD9D bnZlZ4OaBptyQ== 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/8] selftests/damon/_damon_sysfs: support schemes_update_tried_regions Date: Tue, 25 Jun 2024 11:05:32 -0700 Message-Id: <20240625180538.73134-3-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240625180538.73134-1-sj@kernel.org> References: <20240625180538.73134-1-sj@kernel.org> MIME-Version: 1.0 X-Stat-Signature: 9jr3fbhb1jnqyheyfebrnnsw3mkzfc85 X-Rspam-User: X-Rspamd-Queue-Id: D4A334002A X-Rspamd-Server: rspam02 X-HE-Tag: 1719338746-911636 X-HE-Meta: U2FsdGVkX19PORCffQGeYn+2vifyrFWm/akADaojDNQ3rHxzU+8dappn4m6F8rIE7V9MEq0TKbMdwQF9S5qf82rNfhwdocBXPDzP1ZbsISyjpgV4aPgteeJxBBevk5ePcymjYJRqjMkh7TvF9rk0Og3i2Y7PDEy46BhRtIQRW3tVn0lq+WJlQzCCpgeg7xBfFFTtbF2wWTtpaFx0EKITdI2/7cpL+nMCfVUv2uha8Zx45gIpRa9RYhDemvuat2LMRXGCgpjEvO3p8hAnv/PtoTS8iaJGcG665h3JDKUm1TXEd+nvp2W7hG52IFgu+WNTYSaxGi15lCi3gK1qCHdFnN4RYT7itn3mFHajzeK9rhEb6FTJQb8UP0Y2NxzYXI5tzTOiIDOZ6LgqVV7ibnjAUAh6J879x4tcTQ4PZcPcMkMYOrqHmRyhHH9HFWLU+jjnCOtGLvtoKCg4bxd3UZra7DsTjcZ9bxGalZlG7yJwZwKm0GQU4GLdGpShM19ocnd7kQ3bjhmEwI355rYDBq5Pp/hP+fsbsPW0pH4OOIClPrnHdA+6gjoFLg3G/Y0hXkFbwvuigTITaPy3jxLOJ5FfOhtxbyraF0giyHRwxGxG7YkuNIQ4I/UeeQ4/T5qI5qRd95g9sqD0A1RR/Mbkoh+Oyc1uIidsUBq3dE1Yy0EoQ6bSlIVsxCnpoTl1Tu6fDi+Lh36lvSulGpublazeIRfV5Tn5JgSAlqcJaQvBY2OGwqxyWe38VHIdmsxtfj8dXBFoTf7AYWKkXwoTzstu8Ls8ByO55THvkj7oqM/ph/inA0vvT3Iqwe/kin20c9ak0FgEbUzbOhxtVR06B19tED1i35RTlUMiAQp8lAcpikspqLKPrFxfCnBkaHKddPpZOKBk8n/WeXMsu+t5cPAB6O1i/1jY1pBVYn5lKF94Q0zPfh00r+utwzayWp/qYpW6SFabPRLJx0ZJxCyIhVgLxpB KEeQRu5R 7FAT1Jjbxsbns/oEmDPebiWvZ/mf36fVbnIRPhPaLEqI+SDUwN32uNsXT5MoAu9ZwqgvTgqn6UtH3DiIvIIvmfJ38AzuX9EjNXmmohcti8BduosVjddXU5JMrVg35piSVVVBw2O/Wza49Gjx3mVMZGBdUMBgbmBU8eyWi/KzRY72k71XPcxW4R6ltwU1sjG4EIU2Da/HZT8/st8uOvi22vQBvNkFRCFcMJpAGnvbmEZI+eC5dIlqxAGHAv3xRGK4XVu5GGyiKefvIcNNdPqNJGFdoBolGJbLhpcmO 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 schemes_update_tried_regions DAMON sysfs command on _damon_sysfs.py, to use on implementations of future tests for the feature. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/_damon_sysfs.py | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/damon/_damon_sysfs.py b/tools/testing/selftests/damon/_damon_sysfs.py index 2bd44c32be1b..f975742f29b3 100644 --- a/tools/testing/selftests/damon/_damon_sysfs.py +++ b/tools/testing/selftests/damon/_damon_sysfs.py @@ -175,16 +175,24 @@ class DamosStats: self.sz_applied = sz_applied self.qt_exceeds = qt_exceeds +class DamosTriedRegion: + def __init__(self, start, end, nr_accesses, age): + self.start = start + self.end = end + self.nr_accesses = nr_accesses + self.age = age + class Damos: action = None access_pattern = None quota = None apply_interval_us = None - # todo: Support watermarks, stats, tried_regions + # todo: Support watermarks, stats idx = None context = None tried_bytes = None stats = None + tried_regions = None def __init__(self, action='stat', access_pattern=DamosAccessPattern(), quota=DamosQuota(), apply_interval_us=0): @@ -398,6 +406,31 @@ class Kdamond: err = write_file(os.path.join(self.sysfs_dir(), 'state'), 'on') return err + def update_schemes_tried_regions(self): + err = write_file(os.path.join(self.sysfs_dir(), 'state'), + 'update_schemes_tried_regions') + if err is not None: + return err + for context in self.contexts: + for scheme in context.schemes: + tried_regions = [] + tried_regions_dir = os.path.join( + scheme.sysfs_dir(), 'tried_regions') + for filename in os.listdir( + os.path.join(scheme.sysfs_dir(), 'tried_regions')): + tried_region_dir = os.path.join(tried_regions_dir, filename) + if not os.path.isdir(tried_region_dir): + continue + region_values = [] + for f in ['start', 'end', 'nr_accesses', 'age']: + content, err = read_file( + os.path.join(tried_region_dir, f)) + if err is not None: + return err + region_values.append(int(content)) + tried_regions.append(DamosTriedRegion(*region_values)) + scheme.tried_regions = tried_regions + def update_schemes_tried_bytes(self): err = write_file(os.path.join(self.sysfs_dir(), 'state'), 'update_schemes_tried_bytes')