From patchwork Wed Feb 7 20:31:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13549051 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 4BB8DC4829A for ; Wed, 7 Feb 2024 20:31:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A98366B0075; Wed, 7 Feb 2024 15:31:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D23C6B007D; Wed, 7 Feb 2024 15:31:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 786246B007E; Wed, 7 Feb 2024 15:31:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 6B7E26B0075 for ; Wed, 7 Feb 2024 15:31:45 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4D17D1602BD for ; Wed, 7 Feb 2024 20:31:45 +0000 (UTC) X-FDA: 81766153770.24.3448810 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf20.hostedemail.com (Postfix) with ESMTP id 9745D1C000D for ; Wed, 7 Feb 2024 20:31:43 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=XdziAUn9; 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=1707337903; 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=z0T7CeVYOD9GKKEfBy3IV150lcFUebiMsZa/LbzzEfc=; b=qk5wiluDLllBU1Ybd2B4BGxE6Jj+esOaSYadO2sGVPz2Ey22L6VBmmqGeEPRCb44Z7yyj/ s3e77rJ0goByMvp49OT+EPCkEh1SablaLs6WwsNW366X/b/Wjr3drVEX+W36riNYMrrgv2 wDMpxQ0hFD8uynGEZ0IPj5QgJY/DZyA= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=XdziAUn9; 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=1707337903; a=rsa-sha256; cv=none; b=25bUbkPqufYBsLZI0EHpCd/MEWUQlbd+X9CsAbKaPnQpZMFVn+63/AVMB8S3zxc0INEa0V Uy0sUvL6IZDFRJSekx6bNFC0PYFJJieRl8XKjGnq89yjtr7fUlDwgDpRYRHpNSjiQzXa79 3dm4vBmt+ip4wrM8eIRGW5SrvBT3vi0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id BA2BB61AA5; Wed, 7 Feb 2024 20:31:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA011C433A6; 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=1707337902; bh=SwdeOXExaKQGPJVJ2NaT/lednGj9CW7yt27zl0ck87s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XdziAUn989qZYGouOke5VJZROLyvwJMYpwiWYmq66BUEXenv4+YEFtDUWAJ+A9e46 4RcITM/aROpBnV+7byqwfQVSsuyZPtFLLVl+f8ctcCaXnoDBxj77Kj7brTuY7MxQzf 6NO9ac8gHvUjq74gTlJ4q47izd+Hf6ebBXti6tL+WXPNCl37Qsm8WS036hCLnt6xHx 4B0sBDrpLG1W2uOj69vF8f5540kveMiYpR8ER1drvalND7Cz/HlPbut0+TCVD/d7yH EAs7LM4X6EwP+4OXCl44FY2ZUcPhdn5aGcueatWZCkqpFk+6X66NXx0kXHlRCjKbgK O5Yym670dAtVA== 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 DAMOS stats Date: Wed, 7 Feb 2024 12:31:28 -0800 Message-Id: <20240207203134.69976-3-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: 9745D1C000D X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: nipt7szmf653xdegh9koypsd1jfh5gqa X-HE-Tag: 1707337903-323330 X-HE-Meta: U2FsdGVkX1/PS+dv52P0nQaKNDzpSSQOcRMFqpoabSMLqSP9Hv7X2VDObeqmz7dNKGvEYTW9JvvFIIAn84TDfa5uFNKban9nBwrH/jP4c6gBolc9PMKNSDeToYKazWtDtAx677Tpd/btowIvUu5+13l6cnAJTP3/+EXwBkuYKUNM0qpNDTuMh37Pzv0G6L5qkfKqqlWLCw7z5n1kMecXyYdWc7TxZV86x5xkC/W2lkbMFrD2RCFshlHUczrnlYd3WuznMpF6NWHV+9OYcrcaKkmg0Bp0lFTb4rA6I+RorOkGo0XD8bNn9JAVJlDOUKAcqNRmOGMgJWbHiY/eInwKasbDWKMw7iBknDMss/tKGbyESiLM1cwynBXTHPpzyPATTgk06HtFqJRN9DmzvCjKzX5u2pGmrAAJzAbP9R76ZJxrKAzb8OJIO8fq8vvGb1N34gQjw3RxmmYybqdMgjpITXPRVYWlfhxwWjUCD/6mVDYaJjhPp1qetTjfCFexk582caEu7geF6jJUgVq0U5ERBkO3AHHzNzAUUw8rcI0KLEUpNcpRn8omNRaocnsHsUBCAG2+Cqeam5LDDjA7uNKLW/9bSiuV5NLr8Xl6c5KVV4RrId8cKG3qQwaPRXHB2XpK0eLLr8Bf3GLjvw1F/JcaR6HtvZzhoNsl6Oh67MBX+WX4bCqiXqyMeBGjjvSxLSFEpKxmpYKHzt8M4RoRUUCHfqVf2zEkWitdafrS53ln037DClUa5JBgZdMzN396Bdi6Y1fidqTxI36EOM1dUiq3O/QRLacxR97jkM5BVaZv/4OOzA/JptofSosvZwvjN1nTQekeZQd96i6AM88/X9exN3nY+LfZH6R8q1IYcIj6eloy7gM7ub5xrhwvJG42aPpSONT3j80wbQP7DzaKdZze/fukLA/WRUylC+ZYH/OAFa0zsagRi2oBZOYDeIsc6rk58DH3YtH3YChC6CdB9bz /crwrWTI riwXuIFNsRXZYJwuaBjVnw7rzH2Cfb25o5F8VhoZnx84X9wXTV6SyVOypF0LquJflLgJvrxRKhM9XjQ4RvrW/37ijAYHEyLM4kuJse1+aAOwpwghBkWdCiRUnZAVVl23usKTg8EzKXgV6pla4pn2yxA+/tA39nc4PeAntrVAsIA4CEW7Fu2OPdIr1DDG4xsqHrhKD2jwc/QA/JlwxnPa+rOHzbIOwNurANX1zkn26pGfkD1BMdRm86Z0sLmGpK8/uCb9ue5pL4sRRtbO9Ln73poi0UCOxP2g6CpiH 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 stats. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/_damon_sysfs.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tools/testing/selftests/damon/_damon_sysfs.py b/tools/testing/selftests/damon/_damon_sysfs.py index b4f6e385c564..a75244451684 100644 --- a/tools/testing/selftests/damon/_damon_sysfs.py +++ b/tools/testing/selftests/damon/_damon_sysfs.py @@ -96,6 +96,20 @@ class DamosQuota: if err != None: return err +class DamosStats: + nr_tried = None + sz_tried = None + nr_applied = None + sz_applied = None + qt_exceeds = None + + def __init__(self, nr_tried, sz_tried, nr_applied, sz_applied, qt_exceeds): + self.nr_tried = nr_tried + self.sz_tried = sz_tried + self.nr_applied = nr_applied + self.sz_applied = sz_applied + self.qt_exceeds = qt_exceeds + class Damos: action = None access_pattern = None @@ -104,6 +118,7 @@ class Damos: idx = None context = None tried_bytes = None + stats = None def __init__(self, action='stat', access_pattern=DamosAccessPattern(), quota=DamosQuota()): @@ -322,6 +337,23 @@ class Kdamond: return err scheme.tried_bytes = int(content) + def update_schemes_stats(self): + err = write_file(os.path.join(self.sysfs_dir(), 'state'), + 'update_schemes_stats') + if err != None: + return err + for context in self.contexts: + for scheme in context.schemes: + stat_values = [] + for stat in ['nr_tried', 'sz_tried', 'nr_applied', + 'sz_applied', 'qt_exceeds']: + content, err = read_file( + os.path.join(scheme.sysfs_dir(), 'stats', stat)) + if err != None: + return err + stat_values.append(int(content)) + scheme.stats = DamosStats(*stat_values) + class Kdamonds: kdamonds = []