Received: by 2002:a05:7412:2a8a:b0:fc:a2b0:25d7 with SMTP id u10csp553425rdh; Wed, 7 Feb 2024 12:32:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IGXkuPiQlqZDekYV1DwFK7//wViC4zfbTwj6ZjPJ3T2hUBqm3X2rqu8pcS12ar8f0Lsvpgy X-Received: by 2002:a05:6a21:19f:b0:19e:5517:c33e with SMTP id le31-20020a056a21019f00b0019e5517c33emr6620636pzb.39.1707337950329; Wed, 07 Feb 2024 12:32:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707337950; cv=pass; d=google.com; s=arc-20160816; b=DKzmTD/eKvloRddoG6LCjZ0VXegURTJgfWqJ7X26Ywk72Qc9w0zBz+kJ+VtsUrBzfu E/48L2uaaY38R68K208JalY4WlhydgTVBviYk1z805yCkmWbxGyOr1N4IqRWs9NGtXmu w/Md6/KME1Mc0y267jYVDJD5qIpQn8jkdp0kgmFhJGml0xZ1zPGtFxrW9MMj+BEiBafl jzs/lZTwWEI0Wj5BTM3rOt/NO4IUunXOfo29jVXM6liOiyzVgoVUu4JjM3e2Bh7NozGj BGZvZ+k2wQL8cLe9I2/jAUNUphlIIKqhRy6bohi8uqxO9Hq/tAyMSY71fpSPLfm6htQ0 f2bg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=z0T7CeVYOD9GKKEfBy3IV150lcFUebiMsZa/LbzzEfc=; fh=H9fzoTEH9rPJG9+dnh3KwHa2W0pwpIWfYZECxQ9iTRU=; b=g19qCh4MinLTLzbUqp86ADQUjf4llTWN5pesaURTC09Ev+OJrmd4OIu25n9ymxOdBk ckXVx4oIhO+RBnFRkelxX6PTzxrc7B/bC6ZJeMfS0mamM9eSYCageEgAlGftcBuaMnt/ LIDE/PhvoYGW6bVcVZfJ2BQlrgWWaewU8GlmR6cZrQ26DrslI874xx2Nwlo9+e9ofRng o1mBsqVteWvMuEBq/9wNW2vtf8It77Sinm7KbY4OyS+Gu1vMW//QsxIuM7SNXXTEFqI7 FbkmYpHerJM9RBqJzhAWXB2oS3CQECRCHbYwE8V5Swv2UY0JFB+Ehda1UwQWaFhswaWc aX8Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XdziAUn9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57028-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57028-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCVF+k16LUgjNJm15Tww7+ouqv9SdxdRHnBUgWyV/zUrdD8rL+v5Nb7Zkej/BAzkSjteMEQj5gVeP+rTWMNOGiHSnOoZJGgc73NS0siduw== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y1-20020a17090aa40100b002906859084dsi2452665pjp.36.2024.02.07.12.32.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 12:32:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57028-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XdziAUn9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57028-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57028-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EE4CE28F2EB for ; Wed, 7 Feb 2024 20:32:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E590F127B7C; Wed, 7 Feb 2024 20:31:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XdziAUn9" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A31B76039; Wed, 7 Feb 2024 20:31:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707337903; cv=none; b=dvfrwedygiv5+6KCTzhCxKmQ8xA0VYgLya953AQehl0DfIAc9AVzDArJLCVva6PHGwL9QxsQcq8hE48etBbo82gSCfVgyuOSiI3yfwiBnAnG/aM9qJre1mZOg/5Tw9viPcFMtlh4vCTQM4VTUjPxJFFpoNNd63GInZLKvphzSmI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707337903; c=relaxed/simple; bh=SwdeOXExaKQGPJVJ2NaT/lednGj9CW7yt27zl0ck87s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ecfLvRA1TEPEQhSQSWbXbCecjgtRQ7W0AuPau8kYu3ox5XFJSQtB0Iv7z/aaG8S6ePyd+ZPi+u3B+VWZYRfHLxsHVhG8S25syQbBrWErKYJKcsIBCESnUPI1r0D5lr5+SS1MED4+jRtiQujQRxFCbA5JJ8HgRtv5aWj/aJbI8/4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XdziAUn9; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 = [] -- 2.39.2