From patchwork Sat Dec 2 00:08:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 172728 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp1498931vqy; Fri, 1 Dec 2023 16:18:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IF4FFkl5Z8CI3BRAVCdy/MvuKGQ6AN+a9zvYv16c4dQ+DBuF6vN/fGUWchy3ORRVCITpkLO X-Received: by 2002:a05:6a00:1787:b0:6ce:2731:a084 with SMTP id s7-20020a056a00178700b006ce2731a084mr357392pfg.51.1701476310283; Fri, 01 Dec 2023 16:18:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701476310; cv=none; d=google.com; s=arc-20160816; b=urlvwfR2/MlBa6cEGfut+8yDySYwlZrbguFcwmzH5pePzDeFS76BQPHlJ7mDOtTmNZ BnJ9f8P/psv93sj7fIYxT2XrQXymY5IBjeWpf/vedw58DQeRLUJr3y6wKrdkpHDUhIwL 5tp3NjIvVlWSYEBzR+7LTDFw7bXr7lm8mNcApQEZi7oku/lCtQABgJEIVD3teS/GWEih VPi3UwuDr6jVysesNQdmZvGcVyPEl/5frK3cZAr6cw7SlhCbjFbJUWmhBZxiBpl2lz7D nBi7l4bT7NjhdCurd5QNJG6ehOvfkitz1oUTF54U10u6ey1auSozRB/RrZ63yMj8m+QF EF2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=HB7YT4DZo+K0VqrRFyhIZVeyqMtkSZH657BYvby+SPg=; fh=W+de0FjxL1MlRh6Ly02q9tA2/xTz2DOJsg1VkI/mHfI=; b=UdDTVFSYNlMW4HyKhmOHtRDn6m/GRH+ghIcXq7f1+yh0d89LnH34vt3M9pem1iUGFv JzyyW5Nlc4q3Qv8uSyYhfsqDWXfeUOv5MuqzZcRl25opY56uze/ublCgj8CA3vblYTb9 cI0SKFekwpuxJjsM1jz4DRLDKGUEjg/61+iHYIOjYXA+PR5NiKc0Hjbl/5eRTqUDBKYo 4LjVW/RXcSjm3XnjzC16gdDn4vyGX6N+ESi+uH1YvyYx+UyV94VU7pdnUz3ZaoZMcg/w Aq++P767XWbeE9+Ta35Bh0qOgflgwG/26FpWMdY7YU/5lbFpt6DKI7ZPwoXoZTeS6oRT K4VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=uXPiW5Mb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id bd5-20020a656e05000000b005b9a467330esi4532253pgb.707.2023.12.01.16.18.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 16:18:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=uXPiW5Mb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 08CE680747A8; Fri, 1 Dec 2023 16:18:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1441961AbjLBAST (ORCPT + 99 others); Fri, 1 Dec 2023 19:18:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235320AbjLBASM (ORCPT ); Fri, 1 Dec 2023 19:18:12 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FB6CD6C for ; Fri, 1 Dec 2023 16:09:08 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90E4BC433CC; Sat, 2 Dec 2023 00:08:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701475692; bh=dA3cXZTPwGuBFjfk7vBFspKqwxyw85dB6htp3+62oIU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uXPiW5MbtvQcnrRYD9LYG6mn7RPYtIY3MPhQVnAIMhOAdgc6mI0apmxk5JCelCtZv 6Ef9xyeOkzma+9AS+KiXQD8I/La8iDXltv9baKzkgE40yj4y6v44bDlF1mayazsOI3 SZFeTh4Tmcj02tZnymikNK28FWnUE/o8TbsvA9jgSaCvsqcaXZZVQW4sGpyxYe9loS 65NI2gsSjyWNLTNdcdhF48SDc0MkwKk/ahnphuUPocqrvxadSAe2Ob54OKR3XrkyhS WA+RUPrD1WxoIt4tCTJQpKbfR3p09U/4BYqfCsjWEzLdX8FSzD8WCxE124eZnpBkaY E1BPJj/Hl8xpA== From: SeongJae Park Cc: SeongJae Park , Andrew Morton , Shuah Khan , damon@lists.linux.dev, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 3/5] selftests/damon/_damon: implement sysfs updat_schemes_tried_bytes command Date: Sat, 2 Dec 2023 00:08:04 +0000 Message-Id: <20231202000806.46210-4-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231202000806.46210-1-sj@kernel.org> References: <20231202000806.46210-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 01 Dec 2023 16:18:29 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784127223718375002 X-GMAIL-MSGID: 1784127223718375002 Implement update_schemes_tried_bytes command in the test-writing-purpose DAMON sysfs interface wrapper Python module. It is not only making the update, but also read the updated value from the sysfs interface and store on the Kdamond python objects so that user of the module can get it by reading the field of the object. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/_damon.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tools/testing/selftests/damon/_damon.py b/tools/testing/selftests/damon/_damon.py index 6b99f87a5f1e..e98cf4b6a4b7 100644 --- a/tools/testing/selftests/damon/_damon.py +++ b/tools/testing/selftests/damon/_damon.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 = []