Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1407897rdb; Fri, 1 Dec 2023 16:10:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IHejk/aFCpS9tFtLBUone53+eHbnBSp3hoK9+lO5++j7C4lQuPIf4yZE3/GQ3HJdwM6FigB X-Received: by 2002:a92:dccb:0:b0:35d:59a2:2dd with SMTP id b11-20020a92dccb000000b0035d59a202ddmr369030ilr.125.1701475856284; Fri, 01 Dec 2023 16:10:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701475856; cv=none; d=google.com; s=arc-20160816; b=d7/wKKQmjANSsMDf04bNeoG0OuYFmAnqeDSgpiTscLGVh3u+qU8h4mTw1+CpztjLFl idOl0B8l8uYMYu/rHb8NGjTiUEsnFnNr9ld2fojv3zLGAQwwIWZPr+vyz/dcI9WGKfdh QYaNB6La9v7AK9vvWliTWdfJHbCgLi25wer7D0MCxcz6mnUX2mwCTCKfDWAswA8z7b9Q aZMXKsHZsMsVshzlWdX/b3j4gjTjprcjefAjjV6bk33hd2Pc6lEgppXVIbuD2uHsoKaO SMMNvAEcqsOXwj9Z3EV+GSmNR9KNppyNCwHpe+MY9ahPVGbGBOt2BYysuAQFKgzvk4g3 OPJA== 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=OsypTyUMi/Yh1aH0wXO7Cp4Fx6Odu0Zkog1frADmOxo=; fh=W+de0FjxL1MlRh6Ly02q9tA2/xTz2DOJsg1VkI/mHfI=; b=Z3M668SKL3pU6+3txV6mj7LLURjz9Cugl8JT5yQ30QAq2LRYubSY75S7ok6ZApWS5Y MJMzLXVzW9eEGHD5u78hx7OmNX+safseCGrFyTnGqZkbCv9zjibQ7bDEeUws/Q5SbPKr meoX+064axErthxFotn0FrI7SY29cvnmbFg49v4K59CP8yyFmr78znm3PD6GhRUiikhj 25PtwrnNso5XPPqH/u68zG2bHr7FrXc1B5Oq3mrK62TfMU/idSaZZrqEmCEhBPCaS7iW 2qSDpHn7xrxgs5naWnLP3lxxkJzbAzfSF0CHpImbMAmXmFAl8SgDDrYpBy/yP8xZRHbv TkTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=ftiBRtoD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id i18-20020a17090332d200b001cfec9dcd7fsi227523plr.408.2023.12.01.16.10.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 16:10:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=ftiBRtoD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 1F8AF802589F; Fri, 1 Dec 2023 16:10:44 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1441940AbjLBAKU (ORCPT + 99 others); Fri, 1 Dec 2023 19:10:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235375AbjLBAKE (ORCPT ); Fri, 1 Dec 2023 19:10:04 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C0F41FC1 for ; Fri, 1 Dec 2023 16:09:07 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C2B1C433C8; Sat, 2 Dec 2023 00:08:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701475690; bh=GC7hLao6eamt5j9k8hcen8vPzgOkrgeme7Xf5lpgbH0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ftiBRtoD5yl3wEraHqbN9wNqd+G6GNBLIgbbxpKOrAHe8oFCL7SBEpqsjBQ3FBZjl kJ0M6ueGJRGdyNixjGCs/yCwrSiN7nBkW5cf+rEdlaQjsoqvMrJtS6mUTqdMYIUrWG duoCJbg0mJe1uhfD2luVEvn0EEQBvfItemXsQ8n24Xxtl1H/RsVHr3Kj0QU4Wz+mUM 9zSYm9L2V6rsZyDO5M2QQmhJldTJuxZGroKBuSpCk5DHoBxirlz8Csr0eOaiPeLFmM MHlCMPu6dHhXS7RgkofjSyJaxpu2deByYIQbzJC6XJolAfJ8xa8JM9pIzZOPL0nDHA LsMkoitTUar3g== 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 1/5] selftests/damon: add a DAMON interface wrapper python module Date: Sat, 2 Dec 2023 00:08:02 +0000 Message-Id: <20231202000806.46210-2-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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Fri, 01 Dec 2023 16:10:44 -0800 (PST) DAMON sysfs interface supports almost every DAMON functionality. For that, it provides a number of files and hierarchies that not simple to be manually manipulated, or writing shell script every time. For the reason, DAMON is not having good functionality selftests. Adding an existing DAMON user space tool and using it could also be a way, but it would add unnecessarily huge change that not essential for the test purpose. Write a minimum python module that can further extended to be used as an easy-to-use DAMON functionality test purpose DAMON user interface wrapper. Note that this commit is implementing only basic data structures for representing the sysfs files. More operations will be implemented by following commits, as needed for specific real test cases. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/_damon.py | 102 ++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 tools/testing/selftests/damon/_damon.py diff --git a/tools/testing/selftests/damon/_damon.py b/tools/testing/selftests/damon/_damon.py new file mode 100644 index 000000000000..78101846ab66 --- /dev/null +++ b/tools/testing/selftests/damon/_damon.py @@ -0,0 +1,102 @@ +# SPDX-License-Identifier: GPL-2.0 + +class DamosAccessPattern: + size = None + nr_accesses = None + age = None + scheme = None + + def __init__(self, size=None, nr_accesses=None, age=None): + self.size = size + self.nr_accesses = nr_accesses + self.age = age + + if self.size == None: + self.size = [0, 2**64 - 1] + if self.nr_accesses == None: + self.nr_accesses = [0, 2**64 - 1] + if self.age == None: + self.age = [0, 2**64 - 1] + +class Damos: + action = None + access_pattern = None + # todo: Support quotas, watermarks, stats, tried_regions + idx = None + context = None + + def __init__(self, action='stat', access_pattern=DamosAccessPattern()): + self.action = action + self.access_pattern = access_pattern + self.access_pattern.scheme = self + +class DamonTarget: + pid = None + # todo: Support target regions if test is made + idx = None + context = None + + def __init__(self, pid): + self.pid = pid + +class DamonAttrs: + sample_us = None + aggr_us = None + update_us = None + min_nr_regions = None + max_nr_regions = None + context = None + + def __init__(self, sample_us=5000, aggr_us=100000, update_us=1000000, + min_nr_regions=10, max_nr_regions=1000): + self.sample_us = sample_us + self.aggr_us = aggr_us + self.update_us = update_us + self.min_nr_regions = min_nr_regions + self.max_nr_regions = max_nr_regions + +class DamonCtx: + ops = None + monitoring_attrs = None + targets = None + schemes = None + kdamond = None + idx = None + + def __init__(self, ops='paddr', monitoring_attrs=DamonAttrs(), targets=[], + schemes=[]): + self.ops = ops + self.monitoring_attrs = monitoring_attrs + self.monitoring_attrs.context = self + + self.targets = targets + for idx, target in enumerate(self.targets): + target.idx = idx + target.context = self + + self.schemes = schemes + for idx, scheme in enumerate(self.schemes): + scheme.idx = idx + scheme.context = self + +class Kdamond: + state = None + pid = None + contexts = None + idx = None # index of this kdamond between siblings + kdamonds = None # parent + + def __init__(self, contexts=[]): + self.contexts = contexts + for idx, context in enumerate(self.contexts): + context.idx = idx + context.kdamond = self + +class Kdamonds: + kdamonds = [] + + def __init__(self, kdamonds=[]): + self.kdamonds = kdamonds + for idx, kdamond in enumerate(self.kdamonds): + kdamond.idx = idx + kdamond.kdamonds = self -- 2.34.1