From patchwork Sat Dec 2 00:08:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13476683 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 6CD26C4167B for ; Sat, 2 Dec 2023 00:08:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E65728D007A; Fri, 1 Dec 2023 19:08:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E14EB8D0001; Fri, 1 Dec 2023 19:08:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D040E8D007A; Fri, 1 Dec 2023 19:08:13 -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 C15778D0001 for ; Fri, 1 Dec 2023 19:08:13 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 98BFDA0392 for ; Sat, 2 Dec 2023 00:08:13 +0000 (UTC) X-FDA: 81519940866.04.54A8AF3 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf19.hostedemail.com (Postfix) with ESMTP id E1E231A000A for ; Sat, 2 Dec 2023 00:08:11 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ftiBRtoD; spf=pass (imf19.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=1701475692; 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=OsypTyUMi/Yh1aH0wXO7Cp4Fx6Odu0Zkog1frADmOxo=; b=HrxYvKcxrE0RSknSveOsntkD3qIwh0wgqJQ07LeaDzurM0dIj9H0LztAO4VxSfwczexFtB 39zYw3G0Czhi9C/AkMuGHvf0hFtKqIl+rCQ9YBTb4m4KdX2i9oiR/XoZ20SoWswLwKiWpV 1LTdXPgOVxn1FQunYFrkmsqHX8WTc4E= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701475692; a=rsa-sha256; cv=none; b=lhP+F6mYXUYGRgx7zK3/pk9BwEQ2mdKGQSz0bgYvzCcW/Hb9Svb71RylO80DDbCy6eZhvZ Kw16bxY/UPxY1hxl8ysaCub1Kwl1oIrh6k8eQH0ryoTJZPH7Q7HPtytagRwIxHmu9axLe1 2X3GYZze7kj4iZWARadTkWY3PtaoF+4= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ftiBRtoD; spf=pass (imf19.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E791E61761; Sat, 2 Dec 2023 00:08:10 +0000 (UTC) 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 To: 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 X-Rspamd-Queue-Id: E1E231A000A X-Rspam-User: X-Stat-Signature: giz96gx1x14cap5ns6iwu9swju7uzjhg X-Rspamd-Server: rspam03 X-HE-Tag: 1701475691-896774 X-HE-Meta: U2FsdGVkX1/lZFyYz2eZ9Vii8REi34SvXYE7QEgL1/hQXBcOUIqPvT8TJD6x/8s06qt0nQEU/vQZFMqYIUn9Hd8i86DFLvIlzP4j+fRJBvDH2Xp+wL/6DY7PhN5qdqam7F7hqRdsyZEYboIig+W7/rixOrkmje9mMxjk4qBZV0Sc0djJcd3IQ1d/3gy7Ow4JxOibR4n8z+pZMmUwPULCTIGtmzUMb/iTx7g9ft7WNIVVWOC6QO9gMioJ+SlF8FzGx0ghLP7phw1HRznT0NGp9v8urfDa0ZgVkirfm8S4Hcykr6loZtbncKOC0pkqovFzpwCI34EuKBhvQ3fv0WJyS3OMY1cE85+/W17HSP1EyFdeHmg762dudmOgMyT42bVOtEbtyyRe2Ufo3uGUfiA8K4srZYLnVKv2w/kAingt2G8anT5mijDi8imbWknJvklSy/C0DEwBgPsarBay08AaHYfwgGPYqA51NWVTifpbemgKSE5hUMzgqaupgysnz/X7KIN5ReDK14cxZJ2q2PyL0pELY5HHBUYxAbe+ue/WxzclW+6ozjXH4p10L6VQG3GAvGqZ9Z5iGhEOOaE2abP0zEh0iNJdAPf3949jevKHK8k5cR3D+o5Wj3+9YNhljH42z57aiphpxAFzdDz6ANss3QWegoh03I1GYUe1b5fnx/F4HtMPZ8D5CIknAWzoUiDgJuXZ2ZauHl5Z2E3plLuzZ0AlHy+LvwNAi2dShUZ4xGFReCs8kq3fhbmbT0CKQJDq0IqNS8Lw6GQKV4VsxWkEHWLPeasSf67+tggXxaJiN5MFLEtFJblM8vUbdrJU2KJYAgP4qXVlBWqTmcutffqFjKhUINybmWSZMpH3njyLXnBGj3aW+7a2NEDyAGAGgALqkbQywPwJ0ykCUhMU3P8DMLpVWNN10SqQbw0Rpz9a9wkzKgTJtTuqYk0rwD/N408SvIq82UdpaJ6+eeQcGcH fj4EnSCD CR5XVZJs/B+BFoADvc3ZP4A2BwJmk7LGwJA7xhn4zzjY6lMMollAQTTsnVcnCN0cV75G+lDTlbmPEC8wk2kZqoVo9dfy9rgnexZ5if18hTybsZYJh+oMEo1BCkmjLMLrM9Uo8VI5rgF2CT76j/iK6DMZcBaqjykvyjHXrywDaTpeNG/McZvkYQpCFJwL6zWUvnk5N8DU5cfKogusRhWFbeRmVBIwubJp1taErf+MXNLDF0Ck= 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: 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 From patchwork Sat Dec 2 00:08:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13476685 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 65CDAC4167B for ; Sat, 2 Dec 2023 00:08:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 898E98D0001; Fri, 1 Dec 2023 19:08:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8222A8D007C; Fri, 1 Dec 2023 19:08:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E9468D0001; Fri, 1 Dec 2023 19:08:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5F3158D007C for ; Fri, 1 Dec 2023 19:08:14 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 373691A033C for ; Sat, 2 Dec 2023 00:08:14 +0000 (UTC) X-FDA: 81519940908.24.B99A748 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf20.hostedemail.com (Postfix) with ESMTP id 7D0F41C0019 for ; Sat, 2 Dec 2023 00:08:12 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="St1SM/T6"; 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=1701475692; 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=geJbZJJvBae4jqe1AheshTuaF1oJvqnxOcUWPSWBKx8=; b=U/lV1qHlmtl3c8CIGatpty0PCaQx6JsTFkllt6OnRq8FWTIPmT87HoIGuuPHSurirdNh/E JkPzr0TqKpZMhZFufkKfjDm3SbJFLj4UudI8HbraM0LCo4/e4qUExPnL49pYvOfwqAb9NP 2sunsTxAHuUSp7wc+1UfR85P763CxPg= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="St1SM/T6"; 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=1701475692; a=rsa-sha256; cv=none; b=LLICRqeznjdbwoCd5RUZVqAQsT/SoaxX7NgcILDNu4LdNwsSycyLJYVpn7PnywUidsmWds PeODmr1pqmY+6Gks0U5/ojlbMHES2XKBtPgUOdHMtuMlOmrPDOcGo4U/OAeeyj2TIb/ioT cp0JlA57S2ofB1VayhrT3WvhFPXzLYc= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 89C7F622B7; Sat, 2 Dec 2023 00:08:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF60BC433D9; 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=1701475691; bh=AwGT0TApqer7c6nSE0CIfNlDk2EEXmB7q5dDIYgH5bg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=St1SM/T6xISZDuqc/o8B1ANd9sw6LFQh8VK/f7EoOzTNUR4g7rzXiS1hZynIoPxES +nMkWRfV8caIcUBS38lTfH0DLfRc7n2PovLMBPtG7LJEzDmix7RmY0KUJsbX5bIPO5 GzEClqUyvi0tYdRq7Ekmt0QY2g0MGASEcBPdlUvVT+7/WsPmTtzUCKmVpib1y3Yu/1 B6nAGYY4WjDdUDk5tmZZ8jD2cVq1koMg0oxvSz7odEdd1TWGrzXxSeMrU1tjBQP9fR ZH7SVUwKuWrzURd6+3x387eEKnNktbMqJoeAtaux/7rvndIhARQB0ynXH+g1r8fay5 xYkJVtP412jrQ== From: SeongJae Park To: 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 2/5] selftests/damon/_damon: implement sysfs-based kdamonds start function Date: Sat, 2 Dec 2023 00:08:03 +0000 Message-Id: <20231202000806.46210-3-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-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 7D0F41C0019 X-Stat-Signature: 48jn4ocxkkdgcgqg7k58d9cznr55x6ke X-HE-Tag: 1701475692-464792 X-HE-Meta: U2FsdGVkX1+WLN5kjSf/mJlDa7ve1IyVrwVKm+qwaylFTeIUavyMnY3/WIxNuGuyDiHVM9eMErpmsEHstWaFhP5GvGP2yMJ2E+Q/MnB0sC87D4CgFpzKgM7ksQslZ9olifXHLtnDxzvbfhqyQ5PA46s5kyZkDzEnHRWzJWi0W1XWtWxNb5Uv7LZUce8QRbEIq2dcUJkCQf2SoQIkEPCSR0e6EyEfJTrtnoEFXN0lUVhvI9sG2/izv4JTVqPNYH3rM3UDbzBOJ7caCOB6CV/PrYz5lIJOorFtpp6/Icw60pDtn8wVisS6L92mFWVnp2E3Tc2rgEyrXW+gMIdg7iVhktddDDAjSHFfBrkRolt3Nnk+u71+oW/gvFsJeKBqpRQdkMi72Hgu0Oyg83nMKDL40zR4WODTZPehUlbQmLfNrStE2HVGMiiKfvVcXV3UMmfFSW0UbJCzXWBn67P4WNPR8sswCW6e4//7MdHb9MiHbP4QeLmlMze3MvT1d3Crjj4YbJ+nUe9CjvdjffWwe932qLmeJDYMG+K/98i7mKfTvLV6oo3CPVDptYXkoKcbqK1/swVprDTZbkAFPohKqM14jH/OA8tTonMuQacIbQiYKJVfwktl6ITj0F/84HXR95neGmVGi/UssVBAHZqIqKLKDcPovyWNALUOoDSg83cgMbw9IWtI6hgcIpmsSu+Oy4wbNNT3e7XCXolKXPmRH0W8mXRj2wXAUni7MLGT0oEi7LQUkcib4x2tvKJ1v++rQKn9O9UNNivpINRBmFI9JatDIYnSOoUI5OL8LHUA7YSa3DftNV5832Calb1IFO6lXIOBnr0Pupht5dJktqemJVOv3b9m7bMUxyNvdDoKl6yg/932vDqELLRg82QusJ1XIJ1NiXYGhoLUN0FXdwnV69ckdmfqjXdmABdix1wHnG6U+5FZOu4CCdY7ETAU8ZFIhLi8QVHiRzlY18RzXiEruoR DMwnn1Mp RXjV+TGNRPbWkA2erMKhoJhd7oa3LbinlQW1+wt/bqC/8wfsFVs7eNsTX4gchucS+NOAgxF5+yHDS4GSZ8N0RopmD9hhbSheXlG36bJmRrKTLwlEsdVxLfzY2mbJMA9QtHuN30Pc6Ot0S4oY2Z/2oSnJkS980yrncD8BTrrdVBtyTruMcSU5xVARUTFo7ug7jFZZSvj43NeRgctJdJgFm5LKO7TUJrvLA2aGfiQVwpyNMMJOTi5PPv6y1lAurTfQ/AjeYeq3r1rYnHQWZsDM5EI5SAD0uF1dJ6pfR 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: Extend the test-writing-purpose DAMON sysfs wrapper Python module to support turning DAMON on with basic parameter inputs. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/_damon.py | 206 ++++++++++++++++++++++++ 1 file changed, 206 insertions(+) diff --git a/tools/testing/selftests/damon/_damon.py b/tools/testing/selftests/damon/_damon.py index 78101846ab66..6b99f87a5f1e 100644 --- a/tools/testing/selftests/damon/_damon.py +++ b/tools/testing/selftests/damon/_damon.py @@ -1,5 +1,28 @@ # SPDX-License-Identifier: GPL-2.0 +import os + +sysfs_root = '/sys/kernel/mm/damon/admin' + +def write_file(path, string): + "Returns error string if failed, or None otherwise" + string = '%s' % string + try: + with open(path, 'w') as f: + f.write(string) + except Exception as e: + return '%s' % e + return None + +def read_file(path): + '''Returns the read content and error string. The read content is None if + the reading failed''' + try: + with open(path, 'r') as f: + return f.read(), None + except Exception as e: + return None, '%s' % e + class DamosAccessPattern: size = None nr_accesses = None @@ -18,6 +41,35 @@ class DamosAccessPattern: if self.age == None: self.age = [0, 2**64 - 1] + def sysfs_dir(self): + return os.path.join(self.scheme.sysfs_dir(), 'access_pattern') + + def stage(self): + err = write_file( + os.path.join(self.sysfs_dir(), 'sz', 'min'), self.size[0]) + if err != None: + return err + err = write_file( + os.path.join(self.sysfs_dir(), 'sz', 'max'), self.size[1]) + if err != None: + return err + err = write_file(os.path.join(self.sysfs_dir(), 'nr_accesses', 'min'), + self.nr_accesses[0]) + if err != None: + return err + err = write_file(os.path.join(self.sysfs_dir(), 'nr_accesses', 'max'), + self.nr_accesses[1]) + if err != None: + return err + err = write_file( + os.path.join(self.sysfs_dir(), 'age', 'min'), self.age[0]) + if err != None: + return err + err = write_file( + os.path.join(self.sysfs_dir(), 'age', 'max'), self.age[1]) + if err != None: + return err + class Damos: action = None access_pattern = None @@ -30,6 +82,39 @@ class Damos: self.access_pattern = access_pattern self.access_pattern.scheme = self + def sysfs_dir(self): + return os.path.join( + self.context.sysfs_dir(), 'schemes', '%d' % self.idx) + + def stage(self): + err = write_file(os.path.join(self.sysfs_dir(), 'action'), self.action) + if err != None: + return err + err = self.access_pattern.stage() + if err != None: + return err + + # disable quotas + err = write_file(os.path.join(self.sysfs_dir(), 'quotas', 'ms'), '0') + if err != None: + return err + err = write_file( + os.path.join(self.sysfs_dir(), 'quotas', 'bytes'), '0') + if err != None: + return err + + # disable watermarks + err = write_file( + os.path.join(self.sysfs_dir(), 'watermarks', 'metric'), 'none') + if err != None: + return err + + # disable filters + err = write_file( + os.path.join(self.sysfs_dir(), 'filters', 'nr_filters'), '0') + if err != None: + return err + class DamonTarget: pid = None # todo: Support target regions if test is made @@ -39,6 +124,18 @@ class DamonTarget: def __init__(self, pid): self.pid = pid + def sysfs_dir(self): + return os.path.join( + self.context.sysfs_dir(), 'targets', '%d' % self.idx) + + def stage(self): + err = write_file( + os.path.join(self.sysfs_dir(), 'regions', 'nr_regions'), '0') + if err != None: + return err + return write_file( + os.path.join(self.sysfs_dir(), 'pid_target'), self.pid) + class DamonAttrs: sample_us = None aggr_us = None @@ -55,6 +152,40 @@ class DamonAttrs: self.min_nr_regions = min_nr_regions self.max_nr_regions = max_nr_regions + def interval_sysfs_dir(self): + return os.path.join(self.context.sysfs_dir(), 'monitoring_attrs', + 'intervals') + + def nr_regions_range_sysfs_dir(self): + return os.path.join(self.context.sysfs_dir(), 'monitoring_attrs', + 'nr_regions') + + def stage(self): + err = write_file(os.path.join(self.interval_sysfs_dir(), 'sample_us'), + self.sample_us) + if err != None: + return err + err = write_file(os.path.join(self.interval_sysfs_dir(), 'aggr_us'), + self.aggr_us) + if err != None: + return err + err = write_file(os.path.join(self.interval_sysfs_dir(), 'update_us'), + self.update_us) + if err != None: + return err + + err = write_file( + os.path.join(self.nr_regions_range_sysfs_dir(), 'min'), + self.min_nr_regions) + if err != None: + return err + + err = write_file( + os.path.join(self.nr_regions_range_sysfs_dir(), 'max'), + self.max_nr_regions) + if err != None: + return err + class DamonCtx: ops = None monitoring_attrs = None @@ -79,6 +210,46 @@ class DamonCtx: scheme.idx = idx scheme.context = self + def sysfs_dir(self): + return os.path.join(self.kdamond.sysfs_dir(), 'contexts', + '%d' % self.idx) + + def stage(self): + err = write_file( + os.path.join(self.sysfs_dir(), 'operations'), self.ops) + if err != None: + return err + err = self.monitoring_attrs.stage() + if err != None: + return err + + nr_targets_file = os.path.join( + self.sysfs_dir(), 'targets', 'nr_targets') + content, err = read_file(nr_targets_file) + if err != None: + return err + if int(content) != len(self.targets): + err = write_file(nr_targets_file, '%d' % len(self.targets)) + if err != None: + return err + for target in self.targets: + err = target.stage() + if err != None: + return err + + nr_schemes_file = os.path.join( + self.sysfs_dir(), 'schemes', 'nr_schemes') + content, err = read_file(nr_schemes_file) + if int(content) != len(self.schemes): + err = write_file(nr_schemes_file, '%d' % len(self.schemes)) + if err != None: + return err + for scheme in self.schemes: + err = scheme.stage() + if err != None: + return err + return None + class Kdamond: state = None pid = None @@ -92,6 +263,27 @@ class Kdamond: context.idx = idx context.kdamond = self + def sysfs_dir(self): + return os.path.join(self.kdamonds.sysfs_dir(), '%d' % self.idx) + + def start(self): + nr_contexts_file = os.path.join(self.sysfs_dir(), + 'contexts', 'nr_contexts') + content, err = read_file(nr_contexts_file) + if err != None: + return err + if int(content) != len(self.contexts): + err = write_file(nr_contexts_file, '%d' % len(self.contexts)) + if err != None: + return err + + for context in self.contexts: + err = context.stage() + if err != None: + return err + err = write_file(os.path.join(self.sysfs_dir(), 'state'), 'on') + return err + class Kdamonds: kdamonds = [] @@ -100,3 +292,17 @@ class Kdamonds: for idx, kdamond in enumerate(self.kdamonds): kdamond.idx = idx kdamond.kdamonds = self + + def sysfs_dir(self): + return os.path.join(sysfs_root, 'kdamonds') + + def start(self): + err = write_file(os.path.join(self.sysfs_dir(), 'nr_kdamonds'), + '%s' % len(self.kdamonds)) + if err != None: + return err + for kdamond in self.kdamonds: + err = kdamond.start() + if err != None: + return err + return None 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: 13476686 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 2B6F1C10DC1 for ; Sat, 2 Dec 2023 00:08:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 16E078D007D; Fri, 1 Dec 2023 19:08:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F8EE8D007C; Fri, 1 Dec 2023 19:08:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DEEB48D007D; Fri, 1 Dec 2023 19:08:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id C857F8D007C for ; Fri, 1 Dec 2023 19:08:14 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 9A8D3A039F for ; Sat, 2 Dec 2023 00:08:14 +0000 (UTC) X-FDA: 81519940908.21.7BFD2DC Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf15.hostedemail.com (Postfix) with ESMTP id EC1FFA0011 for ; Sat, 2 Dec 2023 00:08:12 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=uXPiW5Mb; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf15.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=1701475693; 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=HB7YT4DZo+K0VqrRFyhIZVeyqMtkSZH657BYvby+SPg=; b=UWm+aTtMEg7raWR5ceD4Q6jDs7COsE49Jxlbg8z0ZwDcTzyVku8nVtPfmZ82hFBAMt2tKj 45Vqknz94v6pzaqnAHpc7Ek5INewhqehlaSv2a8iMQFrE6kb0BkJY9LddB0duppduHn6vb dGgJPt3/gQ6Ct2HHaGamaurpiRxNXSU= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=uXPiW5Mb; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf15.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=1701475693; a=rsa-sha256; cv=none; b=IZ6+kxzWW5SK7tx0omvF+eq2ABWwgfHGJKB2QlcYeBSujcmQ2dp807+dDbSFE0vYpY+sNo ki3AOZ45s+fg1/NQjZSpF7Yi53pqlO+HoX6E9ZW31YJ7C+wWvxBvxPNQZgr3yeB9RSYuco 1qubcK1U7MH8emLIRHncT5bcKQHCLno= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 3F16C622BA; Sat, 2 Dec 2023 00:08:12 +0000 (UTC) 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 To: 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-Rspamd-Queue-Id: EC1FFA0011 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: nsp46mzpyidjunhb7euhsu93z6e1w7nt X-HE-Tag: 1701475692-723065 X-HE-Meta: U2FsdGVkX1+Zdk3qEDwwqUnyHlXtyBMu67HOCfUfYmQQyUmXXZhkLiOMLRJGuOShJryM0cWxYQGpz9HGiJKacBsn5AkMC8xgayNv3Ur1/vvG7CspUlfm3Pjg2Eyx8seTYeyGzRo4nAFLS/0PNWXtFf6vgMQODO6MJqx13Gcdtv6HGEDHvuMTIkBgYhmk+DSg85Amk+Epllf1fQ1ECU2Bar5YzH1Kpq/nF37RPU+1UA+hK+xoGXXdyem/aTDSLZzrBd4CmJHGQl3P/D0E8Vx2ONzVYZMohGP77OXxfoPbOQoozD8p041saPOstjd6/Vt3En0Ga4fTKb7HXhreb9n8up8mKDjYRjObJaWGrqZHL51SCKo/M4CB/vTNJFWhRsFS6JTGhNjDB2fEzFC82pqCqmZucrrGST1gq1Lbp7gcCYeLbk1XvzGdj3xIqoCUzL9PUUrsPodEDvoSpksDeU5Qm8BMXc8nfgZ2EH/X6CpelrQ4rxXA/UM4GHtCnvGi7YYt5P9w5eoGcQbnNnIZKSEXR15QSaY2dZ5vMPbsgdO35pqBZjjYAdLIv3aQctnJ/EZ4GKKz2gkxj6Pgjyh9HnjDJhjDvJQHTju0VQfwzyNhnLE+iEZe/EqZMOki37HIcriKhuY7PvCW4vK0Z/pYojXjB88emB3Dk869Us9CTPEKatZtdZ952ZszlTcHyEkpvoMdHmPjosHzV+4oMfA+m0XO1fKtGjXUa+RIBIX6y140gKYtg+Z0ReUqclDTFN2Xhy06Ikxa/JoSGocHs8uwn/4m6SjEw09pB5qn7aerc7JhJGqh9I1edXgfVqy+orHove3ySzIogSnL5IOmhkSKN7uFB8G/kgjCmLLJa4GIgd+a29lMMzTHH+IYLnKdP0FrKbUazvyYhL5JjKrtOeuqoj0teMvr+Sqf1G6uEm6sacQoEaEdGJ3MPPwIOD/nSWk0O2SNLY7AWlvPzsWhH6q4sjj Y3t/sJZy EBHBz1DETRFAdyIv5wkeRGlbgBWHiXvP4kwExtn4SDIvPlDfMmd06bh4NLkU1XZj0kr0vaTZWyDhZQgX6LEUSQBku//+ORwfhv0V9c+MOYqf57IGfadBbeL4MBKLY7c3ld5ovsdUAwMsA7AkpdZGdSQncHmzz5wvFRKAAdFLxBsmYuIG+XtzFfH4SNecNnmZhi3Z0GBxlmY9+jpwCWXhakL6C88YEDdSrOdhyogfDu+wXi0E8eXmKLE64ZvaHjc0AhGxNywLwHd9yERbmo5oIOuOUIElgjg9nALgP 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 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 = [] From patchwork Sat Dec 2 00:08:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13476687 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 6437AC4167B for ; Sat, 2 Dec 2023 00:08:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A475C8D007E; Fri, 1 Dec 2023 19:08:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9CFC88D007C; Fri, 1 Dec 2023 19:08:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 897BE8D007E; Fri, 1 Dec 2023 19:08:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 6F5B18D007C for ; Fri, 1 Dec 2023 19:08:15 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 43D89A0384 for ; Sat, 2 Dec 2023 00:08:15 +0000 (UTC) X-FDA: 81519940950.14.C79B16C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf04.hostedemail.com (Postfix) with ESMTP id A1CA940018 for ; Sat, 2 Dec 2023 00:08:13 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eS0GQJL0; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf04.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=1701475693; 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=FzQSkGprvCjYi1PSKTyL9VXCZYB/89pkL/cEpZOg+KI=; b=N+kQRpzHEomePTVoyjSWswl2uZMTIgccYz551sUEXfubuqfgM+P1DRkBw7UNy3XKLmprFs mdp2PLRORNe39ysVk5BU902mm9VtLZaXxnZTExTXLzUrNIqjE6WOv30Nz6sPuQK3TqWBOc vmDmRD1V+leBE1xe4EHgdmFdFcdr7vI= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eS0GQJL0; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf04.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=1701475693; a=rsa-sha256; cv=none; b=1tW7I6sHw1eJMoBnuIIDFABwmlZ2pPEjr9OQNlNFsL6i7SbiEBkY47fw0qDgtw/OnKUvCv K6IfrPsP1AZmrUfcLZ+vyZl7bOZyrt0pCLJYYN96Si9Psmbwx65zsnmB339Kr6ufxDkq7m 4v5jJXF40BsFQIzFVff1+TEIESSdxvk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E3ED7622BF; Sat, 2 Dec 2023 00:08:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4343FC433CB; Sat, 2 Dec 2023 00:08:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701475692; bh=RPGqDNVbRfHZdHfv52ZXw/68V6PB6K+dkXKHSqnAU/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eS0GQJL0HFbLi29VHlV8HHJ66TzvYLdR6ptWgktTsJ+ve9HpARkVXJ/lTBvWM6PZ0 PcWeIAFDosQS6fItHLeCOtbITCASeM/mpK+1bIDecMd3ZDk/GHSdwSI8rnxo4RmEM6 /owzTnEWigKz9PIuqsPveep8ynF6jpKJAPEq+17cmIjo57c/pnE1yffaPTz36+nU3y OovjM/a6n6c2AdBjkFzAk9sPQdD0WWldR607zXYsbdhafadiPe8M1QDMtrlJrVqFvq k2Ig07layGEKD0GjJSSonWptIfJPglIdFsIUjlUhxMw+0sxb4t6zaS7yXbnIipwjtx r0vwISU4ttEjg== From: SeongJae Park To: 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 4/5] selftests/damon: add a test for update_schemes_tried_regions sysfs command Date: Sat, 2 Dec 2023 00:08:05 +0000 Message-Id: <20231202000806.46210-5-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-Rspam-User: X-Stat-Signature: zdqz8ye7bpnhwhtjcatopaakubgyn8q9 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: A1CA940018 X-HE-Tag: 1701475693-650195 X-HE-Meta: U2FsdGVkX19S47vvUUSxdKR02SWZLTVCeJNQAb1sGt5gsJb6DQdYqgmHMhwcBm4jABs4HyxbUMr2tGVL+uoOj7TVUOeFVceKpmPRnhKWWDb6R5cTjPCj6z37ntPc/5NbfrmNIXIEqR9bFPBzgwrpWoNB04n/wBXhAMtsaA4FpY8eLSNvx95BKMYrLlRr4bPT6sAhlsEcMqNI4VxIIWqt2Cg6QCjTy/9ASiUoMxd2mq3U39GPxi8LEYhG5Egy2ZgMjJLpaPebThbfFpmOMQpBcNZS2DWRIsUd9zQluaJP5+85uP1xMqHAVCxcyvX1dHek6l9yxGnSPZqQZHovfCmI//8/z5PqjijhuwqS9FX1om5f3iEOaIWYWEjKOrD6yNf02husCidYAJ9QbUzpiks6Zepz9/JQ2P3z4pvcveMOFPAVP+X7Vd6699sY9EcrwRGKqEtbhaXdF5ej4YILSVnByAkJbrCzfsWWWlIqAvmA0GC/QRIYdQQI2YMaqwRhxxva7T/rRfvtarAbeNcibgoRECxO1nLeGSKGLrEZRz/+lyOF4Vpx8wUotd3gm/D2UgpR4m0FBgfORNlDGArY+w8QFU2e8qndUfX9+pildPlSJRlGf7crc7ghSEEdxQ5BY9uF8QHUaqsVRyBudqv/2ksy94usypI1YLlcEbhp7zTHURxTfhFbpJl+buaFQwe1qAzu1yaiqfbIRIJ656G1MU2uVLxQrYja81oqvU0JYrwRKP+oVNg3izSxg1XejNOYmTMyuidEL3otO/AuIyCF6FEajsAeE3xRC7tC54Vy0Yx4bHJmJ0VLuPKW8ICEBE4kID49no0oK/UJ+q/+A7bD/q2mEcD031ieMwCnsDH8pDN2/WLTnzhRsMCyG3NV7KJ5pK2gYhy9ROS05vtFQ2dre0TS9kBKb6lOkSUvbWELBY5C7U3DRJfV5fUL4RP+hr+EtyzyU/9ja//TOUW3KGmxo8J hmFbrxEs kvUoFvA1wEwORZA7y6ziVcImM2BIp8WfWr+VG1PIKEu+aq56cmoT2AUdtRFl1bQ9JIan7qIdQzPtzQ59sRJGkjKmUPKTbiJAIXhKdWVovJEgGBolmbOxj+fBb4qtcgPdH6Lg3QjwZIUht30JXo7MMtSqJItdoyvOFzl76v4YPFJZv0hC6/Ae01ftnb2OAjugHxWkCtzG3+J9s7zPD4xl0WJoXbd4DC67WZA73O+lheiKC0pAuujueHF6ETcpsefaHpGNRhpA6zRXydrbXUaiUYqJbNag2aGdnvCiM 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: Add a basic test for verifying accuracy of DAMON's access monitoring functionality. The test starts a program of artificial access pattern, monitor the accesses using DAMON, and check if DAMON gets working set size with reasonable amount of error rate. Note that the acceptable error rate is set with only a naive assumption. Failure of this test may not always mean DAMON is broken, and we could adjust it in future. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/Makefile | 2 + tools/testing/selftests/damon/access_memory.c | 41 ++++++++++++++++ ...te_schemes_tried_regions_wss_estimation.py | 48 +++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 tools/testing/selftests/damon/access_memory.c create mode 100755 tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_wss_estimation.py diff --git a/tools/testing/selftests/damon/Makefile b/tools/testing/selftests/damon/Makefile index d2105d41ea25..1363987709c6 100644 --- a/tools/testing/selftests/damon/Makefile +++ b/tools/testing/selftests/damon/Makefile @@ -4,6 +4,7 @@ TEST_GEN_FILES += huge_count_read_write TEST_GEN_FILES += dbgfs_target_ids_read_before_terminate_race TEST_GEN_FILES += dbgfs_target_ids_pid_leak +TEST_GEN_FILES += access_memory TEST_FILES = _chk_dependency.sh _debugfs_common.sh TEST_PROGS = debugfs_attrs.sh debugfs_schemes.sh debugfs_target_ids.sh @@ -11,6 +12,7 @@ TEST_PROGS += debugfs_empty_targets.sh debugfs_huge_count_read_write.sh TEST_PROGS += debugfs_duplicate_context_creation.sh TEST_PROGS += debugfs_rm_non_contexts.sh TEST_PROGS += sysfs.sh sysfs_update_removed_scheme_dir.sh +TEST_PROGS += sysfs_update_schemes_tried_regions_wss_estimation.py TEST_PROGS += reclaim.sh lru_sort.sh TEST_PROGS += dbgfs_target_ids_read_before_terminate_race.sh TEST_PROGS += dbgfs_target_ids_pid_leak.sh diff --git a/tools/testing/selftests/damon/access_memory.c b/tools/testing/selftests/damon/access_memory.c new file mode 100644 index 000000000000..585a2fa54329 --- /dev/null +++ b/tools/testing/selftests/damon/access_memory.c @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Artificial memory access program for testing DAMON. + */ + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + char **regions; + clock_t start_clock; + int nr_regions; + int sz_region; + int access_time_ms; + int i; + + if (argc != 4) { + printf("Usage: %s