From patchwork Tue Jun 25 18:05:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13711791 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 85672C3064D for ; Tue, 25 Jun 2024 18:06:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DE446B009F; Tue, 25 Jun 2024 14:05:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 186286B00A2; Tue, 25 Jun 2024 14:05:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D3CAC6B00A0; Tue, 25 Jun 2024 14:05:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 9ED6F6B009E for ; Tue, 25 Jun 2024 14:05:51 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 39A64160411 for ; Tue, 25 Jun 2024 18:05:51 +0000 (UTC) X-FDA: 82270189302.23.7978C09 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf16.hostedemail.com (Postfix) with ESMTP id 17B1018000F for ; Tue, 25 Jun 2024 18:05:48 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bu47WY5C; spf=pass (imf16.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719338741; a=rsa-sha256; cv=none; b=s2FrVRDj93VjIM1SHvWuZR7/TNtIi0Qebf4c/xcIEXG9eNpNoLqPrytVgEQYlW8KwblHw1 6CIDV+SfesdwDkhzRcyMqh3D4sr8uvr9dIwiA670RmcaTnYpj3OZf1MSyWbuFzvS8yMWfF EdAmOatTbHopQwhSYE16ppE2B13owXQ= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bu47WY5C; spf=pass (imf16.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 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=1719338741; 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=PIV7EMBbyn+rg2pNEGrc9L9bALGxo0H0TA7Y0JCLUIA=; b=n/gxCJlO/aVs+0pDBZfsPy9zKvFkuMPDc71K41Mw8Aw1Ih2qBk8/0YuLBA33w1l8B3tPK3 fgsFQcQKSR1pMtapJN9/NZscJXPsP/RiW9OG7Xzuz+oyiOQXOF2zNfEdfjEpPyERa+lVMO iVXynb+X3/9yr0X8YNuOwk0jTkFjACU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id AB111CE0D4E; Tue, 25 Jun 2024 18:05:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69C14C32782; Tue, 25 Jun 2024 18:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719338744; bh=1TXG9SZrMDwPCPN1jihDIbGlXNgSRELots2zUsHDeb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bu47WY5CMcvz7hkGfMSJ2ELpSfKOgCjBYGqBqcSlmujahvS5mLk5/0/RqH31GIAq3 viEOPXasgnf2Bj/tW6jbbfRnYknmObLlrzy8U3lmX7dDR8v458+VGlKPrD6Cl2Jf55 JB0qK1boaZF/go0H3yZHxDp8cw+FroebV6s8ho7ZWsYgCROwQbbdUMVBq7Axj7YujR H5qEHPZRB/Fs2UpvtxwHvX6y2VPoMmJ4nobljvvqRNR3sSgrCQmp54+RwTxCU86hC3 mqo6UPK+gl+gPGply5HtOyHnDDdFJldiXlzVh4P/hfK8oJp38yCkyjvu6eFAae7kO0 jn7MW6yAW0s2A== 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 1/8] selftests/damon/access_memory: use user-defined region size Date: Tue, 25 Jun 2024 11:05:31 -0700 Message-Id: <20240625180538.73134-2-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240625180538.73134-1-sj@kernel.org> References: <20240625180538.73134-1-sj@kernel.org> MIME-Version: 1.0 X-Stat-Signature: a9tyhydhah6p5bzefxeejbgeaisga16z X-Rspamd-Queue-Id: 17B1018000F X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1719338748-98763 X-HE-Meta: U2FsdGVkX19LKR7HB/zIK5pQW4yGwF6/3kdVXXUu0EOQYbv39lVnBwW4ZxcdqKepQnEgePLTVcQA1+XIpAuE+Aw3umamZATqmivcSU8uExJP0XQFevYd+AENP+rjYb2MBono0x17/HhGd9TYbDDxPLQbI0Llyl9kiiAroQ8KuI2RC79A8cpNtqWsDzL+Ld24SbD4OUlDdqXBiayI0BiNReaNirrXZgIi46OmfULuH1ZMDLqwW0LQoIhUDyNwkXH4kekU2BHd6S6dRYB+3zRxzrksJh7xmg27Afx2Ug1wLVrMk7K5W/VmsR9/oezT6dGadammF8NBpVfbFz1UZHhttucWIt+NY9CdmVcKD2Zknx8EEbtp6Le0f4kaI9+/UGi2pTcyyFvGty1pegWXkkeHVOUqsOhZUzSpEJHJWXEXfYXFfkbaGtHN8RUxFCbX0jK/Cs4kbc7BrZID6hWNMzU5VQ+2dv3k+mk2dw77OwiFtArEhPQhgUfFX6PhtunZMKL0kGHmGB0vQfofvujgfLsg6C5p/6hAypUEUHtS/VW2dvvpiTeZTro/hiYWF6Mldu+VBeWumMR6+aBVaFKzGxeaCM1hf/z0OB6LwYSdzQ7oX2+PXqr/FdFKlhoaQkU4DzUz9p6GEj7c6U4y6VY9+k5XAIpE1eG0KWgCYGibn9n7RXmsa2huRfIt6Eq/m3S7IdnWidMVFIsAYhL+ffZ48Q61jV2l/ScGlvgBbZz/vzwYL9VDvahtxzbgGNbCbq/Ud5qZIJ+GdrKHggHzQrZ9kbyPufTULWRKpCzYoD7F4KYURaWD5/Hm2cnYgHqGHj8W+1yeyOOmlqv3z4Lmq8amGXfJrV7APlyA/XxBDhJqyE7z7Z4eYMK3QfUtul2xWx7wyu+0rnB3kkd062BZ7beqhUvaEpKotPRrDa9vsMz/y1TwMEPTuM4R2JZPsXwo36Aau+E60YsqDJ4S2nooYxnzXbp CGBI6Cv4 0INSqsQrnasYyLKV9LnTjyq5WdWLmQG89z/5aorMQMnQx7eL+CslOjEKLgqq3PJ299vmNIlXkpQWgA+aOH7iwLp7DUXi2qtsAY/RWeZVefi0abU3KdG1Y09yOCyuRCzgnPiXkMC3xTJndntzGG4iDpAVNoJT9jY/8HT8l+tPFraYisXgJ3EmFGMAcZEV81xuZtxAIIvcpRF87iPHZYfh0JWxKoXz7DnYWl92/qdcZZQ18mAxO+cB9mE5b5V8bUDOd5GjgwhnL3PeKhPGsOKS2uxTylw== 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: 'access_memory' is an artificial memory access pattern generator for DAMON tests. It creates and accesses memory regions that the user specified the number and size via the command line. However, real access part of the program ignores the user-specified size of each region. Instead, it uses a hard-coded value, 10 MiB. Fix it to use user-defined size. Note that all existing 'access_memory' users are setting the region size as 10 MiB. Hence no real problem has happened so far. Fixes: b5906f5f7359 ("selftests/damon: add a test for update_schemes_tried_regions sysfs command") Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/access_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/damon/access_memory.c b/tools/testing/selftests/damon/access_memory.c index 585a2fa54329..56b17e8fe1be 100644 --- a/tools/testing/selftests/damon/access_memory.c +++ b/tools/testing/selftests/damon/access_memory.c @@ -35,7 +35,7 @@ int main(int argc, char *argv[]) start_clock = clock(); while ((clock() - start_clock) * 1000 / CLOCKS_PER_SEC < access_time_ms) - memset(regions[i], i, 1024 * 1024 * 10); + memset(regions[i], i, sz_region); } return 0; } From patchwork Tue Jun 25 18:05:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13711787 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 7A5CDC2BBCA for ; Tue, 25 Jun 2024 18:05:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 12F066B009A; Tue, 25 Jun 2024 14:05:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0DD976B009B; Tue, 25 Jun 2024 14:05:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC0416B009C; Tue, 25 Jun 2024 14:05:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id D21F16B009A for ; Tue, 25 Jun 2024 14:05:48 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 8D08340466 for ; Tue, 25 Jun 2024 18:05:48 +0000 (UTC) X-FDA: 82270189176.28.0A67FA2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id D4A334002A for ; Tue, 25 Jun 2024 18:05:46 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=owYguYF0; spf=pass (imf11.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=1719338735; 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=3pO6xUwej+8deW8c5rOcwx8Ubgzhrx8CE82GCD55xXc=; b=xCufeywG7/SZzeApAR2HqQB+bOx2Q/+T+S+h9jh4g8CXTpcHdA9PtVU+xzHNohohBHhctl k01ymA4MLkUJ3JmMDAF91go+Y7sf8qlW4UdKgOTxiZilOF0LTKtzKW/BIJ9ItSPCKYPIqt /vbCe31AUlHs8u5ny7MDN7XU9F6NFb0= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=owYguYF0; spf=pass (imf11.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719338735; a=rsa-sha256; cv=none; b=SThkh5WPqYvi9gJ0ZZNEKVi8NmmHeMpPmMMqv6Thi0bw1EiC1eY8ihPm2pmAhDXTQMxoUH IFa9JtGFEBzwr8vxm89vMM9WfQOc+nB7jn1KxFJiq6H6vb2NiK5evwefZT4ZiUM3EoNjc0 TnxtJn6fw8Z9EQM0bMCB3WmAlEA7sN8= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D547C616D8; Tue, 25 Jun 2024 18:05:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20FCAC4AF11; Tue, 25 Jun 2024 18:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719338745; bh=IqlT1IPKcASfwAbySeLSD/8umJwtipY7yMwxEMFH+lY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=owYguYF08Cx4JYwOY6o1g0owoG2dsbNcaU/uOyKCAB27ayZjRretUhozMpE1EHQlu Aj/K7T8lVNM7nt8K2aJagUURVKGF67WC2KKzKvP+ndwQ3nlbi/8hIhtH4xJJwEwWMC ThpMW7G8krb7u9VhvABkwUTDXPcgKXz2DBHuNhgWEaVQl394tetaG8Ms9gUq5MH2sS aS+Rv3BrsQ4PHUfZhg9IkyG8wZvNHeeLcdD4K1a5CBmgnPIjFRZKzgHV9xNgresdvb aFOt+PLj2NZTMUdfPsJUIpGXnhZePKEGbStW8i8bxkRVLIiz5q1uhRGX2tOE6rOD9D bnZlZ4OaBptyQ== 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 schemes_update_tried_regions Date: Tue, 25 Jun 2024 11:05:32 -0700 Message-Id: <20240625180538.73134-3-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240625180538.73134-1-sj@kernel.org> References: <20240625180538.73134-1-sj@kernel.org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Pfh00r+utwzayWp/qYpW6SFabPRLJx0ZJxCyIhVgLxpB KEeQRu5R 7FAT1Jjbxsbns/oEmDPebiWvZ/mf36fVbnIRPhPaLEqI+SDUwN32uNsXT5MoAu9ZwqgvTgqn6UtH3DiIvIIvmfJ38AzuX9EjNXmmohcti8BduosVjddXU5JMrVg35piSVVVBw2O/Wza49Gjx3mVMZGBdUMBgbmBU8eyWi/KzRY72k71XPcxW4R6ltwU1sjG4EIU2Da/HZT8/st8uOvi22vQBvNkFRCFcMJpAGnvbmEZI+eC5dIlqxAGHAv3xRGK4XVu5GGyiKefvIcNNdPqNJGFdoBolGJbLhpcmO 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 schemes_update_tried_regions DAMON sysfs command on _damon_sysfs.py, to use on implementations of future tests for the feature. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/_damon_sysfs.py | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/damon/_damon_sysfs.py b/tools/testing/selftests/damon/_damon_sysfs.py index 2bd44c32be1b..f975742f29b3 100644 --- a/tools/testing/selftests/damon/_damon_sysfs.py +++ b/tools/testing/selftests/damon/_damon_sysfs.py @@ -175,16 +175,24 @@ class DamosStats: self.sz_applied = sz_applied self.qt_exceeds = qt_exceeds +class DamosTriedRegion: + def __init__(self, start, end, nr_accesses, age): + self.start = start + self.end = end + self.nr_accesses = nr_accesses + self.age = age + class Damos: action = None access_pattern = None quota = None apply_interval_us = None - # todo: Support watermarks, stats, tried_regions + # todo: Support watermarks, stats idx = None context = None tried_bytes = None stats = None + tried_regions = None def __init__(self, action='stat', access_pattern=DamosAccessPattern(), quota=DamosQuota(), apply_interval_us=0): @@ -398,6 +406,31 @@ class Kdamond: err = write_file(os.path.join(self.sysfs_dir(), 'state'), 'on') return err + def update_schemes_tried_regions(self): + err = write_file(os.path.join(self.sysfs_dir(), 'state'), + 'update_schemes_tried_regions') + if err is not None: + return err + for context in self.contexts: + for scheme in context.schemes: + tried_regions = [] + tried_regions_dir = os.path.join( + scheme.sysfs_dir(), 'tried_regions') + for filename in os.listdir( + os.path.join(scheme.sysfs_dir(), 'tried_regions')): + tried_region_dir = os.path.join(tried_regions_dir, filename) + if not os.path.isdir(tried_region_dir): + continue + region_values = [] + for f in ['start', 'end', 'nr_accesses', 'age']: + content, err = read_file( + os.path.join(tried_region_dir, f)) + if err is not None: + return err + region_values.append(int(content)) + tried_regions.append(DamosTriedRegion(*region_values)) + scheme.tried_regions = tried_regions + def update_schemes_tried_bytes(self): err = write_file(os.path.join(self.sysfs_dir(), 'state'), 'update_schemes_tried_bytes') From patchwork Tue Jun 25 18:05:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13711788 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 9A999C30658 for ; Tue, 25 Jun 2024 18:05:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CECE76B009B; Tue, 25 Jun 2024 14:05:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C75BF6B009C; Tue, 25 Jun 2024 14:05:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA0C06B009D; Tue, 25 Jun 2024 14:05:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 8E0FF6B009B for ; Tue, 25 Jun 2024 14:05:49 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 11FBA1A04AD for ; Tue, 25 Jun 2024 18:05:49 +0000 (UTC) X-FDA: 82270189218.28.C3C0583 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf08.hostedemail.com (Postfix) with ESMTP id 5C729160028 for ; Tue, 25 Jun 2024 18:05:47 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Sc+31Mqf; spf=pass (imf08.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=1719338740; 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=ZDBxekQlPQwRWv8NbSLt34g4USSPft0WGC4baLFlqZo=; b=OrI1A5FF5Lyp9f7xd1rq7nb6abVxb4uL1qHSwDWo6Kp4sHKm4Hnm6MvlyDfQLHd9GQr29n feLOIew49ZqxQ8TZDydkDO9/MxMFrNBjIamzhz9QJgbXdAPBAuKY9DGW3k6UzKDm8IsYug D1ahCFX9EwhC2ePth8TsDtFZWPaymsE= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Sc+31Mqf; spf=pass (imf08.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719338740; a=rsa-sha256; cv=none; b=yqBXeb3aEcbCMzQKTM/AaCoX80KBYQW+sIyMgipIjmPpwgGHP0wMHrpRRpatPGI2goVOux 6xv7C7JmZayDMLZgJHco/SHncdlMZltq86tTXr1k+fALWr1mhDVorAWVmdq0nPZvJpJV2X Bhdx/3GCnyi9mzTK/TD3TpMhhk3ipaU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 8BC0B616B5; Tue, 25 Jun 2024 18:05:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAE19C4AF0A; Tue, 25 Jun 2024 18:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719338746; bh=ywuSH6qCkdeHkBE80ZCaTZoKmSWBRtvzgEieCdzLvOc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sc+31Mqfm7OWQ/QmyXmPnb6jz1ppHcjAVkVMJ103bsVJhmTZeMfZSEzV0KfD463mE Jfa3Ujynn3hCCArqzfJyoQk0aNGRgAf7QpPtNGn/1JbrBpQXkp/TBfc/VKg5eqi9Bp 4pZn6ivEFleWQ08gkTga3GNnGE8dJIqueR/Xu8PYWmAVmda2ZMZPe23GZE8RBO9AvX 4GRqw/WU6iEV0kYPjq8Z8oMCo2/COA1yLCqidJZjFsKOt63LyFdZvxEGWCyUElhuFm MUzVwaBzNnFJYumVJC+UaZbqqfLgkonFu9qi5myPcSoQ7P2pjo+A3komKxNcWG3waB ixjwGIK9+g4sg== 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 3/8] selftests/damon: implement a program for even-numbered memory regions access Date: Tue, 25 Jun 2024 11:05:33 -0700 Message-Id: <20240625180538.73134-4-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240625180538.73134-1-sj@kernel.org> References: <20240625180538.73134-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Que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iIM4nkg uQraJE32Mz5aQzx7ACkyM+WHrXhJjO2T0A8m/G+f27sK5Z0UM5fSTULDfG5a2KibJ3SzNht6tUX9OMnCehtxLfIzACr5TqgqapGF8vP8BgypAWFbFdOWcdE9E++N38Nl4JMpEvW2sunzaPU0LaCdJFQOajngCQC1Ij53eipD91xNPHnVJWIu0JdztQNcrCPmgCYtyhB8vmxqfLLOj+99Nmy5lPtX3BlGAfuJNsdkcLsGMaz4= 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: To test schemes_tried_regions feature, we need to have a program having specific number of regions that having different access pattern. Existing artificial access pattern generator, 'access_memory', cannot be used for the purpose, since it accesses only one region at a given time. Extending it could be an option, but since the purpose and the implementation are pretty simple, implementing another one from the scratch is better. Implement such another artificial memory access program that alloctes user-defined number/size regions and accesses even-numbered regions. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/Makefile | 2 +- .../selftests/damon/access_memory_even.c | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/damon/access_memory_even.c diff --git a/tools/testing/selftests/damon/Makefile b/tools/testing/selftests/damon/Makefile index 29a22f50e762..7b972b5cf487 100644 --- a/tools/testing/selftests/damon/Makefile +++ b/tools/testing/selftests/damon/Makefile @@ -4,7 +4,7 @@ TEST_GEN_FILES += huge_count_read_write TEST_GEN_FILES += debugfs_target_ids_read_before_terminate_race TEST_GEN_FILES += debugfs_target_ids_pid_leak -TEST_GEN_FILES += access_memory +TEST_GEN_FILES += access_memory access_memory_even TEST_FILES = _chk_dependency.sh _debugfs_common.sh diff --git a/tools/testing/selftests/damon/access_memory_even.c b/tools/testing/selftests/damon/access_memory_even.c new file mode 100644 index 000000000000..3be121487432 --- /dev/null +++ b/tools/testing/selftests/damon/access_memory_even.c @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Artificial memory access program for testing DAMON. + * + * Receives number of regions and size of each region from user. Allocate the + * regions and repeatedly access even numbered (starting from zero) regions. + */ + +#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 != 3) { + printf("Usage: %s \n", argv[0]); + return -1; + } + + nr_regions = atoi(argv[1]); + sz_region = atoi(argv[2]); + + regions = malloc(sizeof(*regions) * nr_regions); + for (i = 0; i < nr_regions; i++) + regions[i] = malloc(sz_region); + + while (1) { + for (i = 0; i < nr_regions; i++) { + if (i % 2 == 0) + memset(regions[i], i, sz_region); + } + } + return 0; +} From patchwork Tue Jun 25 18:05:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13711794 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 62133C2BBCA for ; Tue, 25 Jun 2024 18:06:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7E53C6B00A3; Tue, 25 Jun 2024 14:05:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 771316B00A4; Tue, 25 Jun 2024 14:05:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 572F46B00A5; Tue, 25 Jun 2024 14:05:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 3628C6B00A3 for ; Tue, 25 Jun 2024 14:05:53 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id E7D5140474 for ; Tue, 25 Jun 2024 18:05:52 +0000 (UTC) X-FDA: 82270189344.30.68860EB Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf30.hostedemail.com (Postfix) with ESMTP id AAB6C80014 for ; Tue, 25 Jun 2024 18:05:50 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YZW6FvAs; spf=pass (imf30.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 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=1719338739; 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=B8slzHya3WIlcdLlFMEaAHcTjmAk6AdBOUF0o2JvV1U=; b=AFY7qofnVD6Vj7MsntdjjUtUAZVsQg19C/+fX1pxHmvARLuoisql8Klmf0Ap/whatDioi/ poE9EFNViuC2GqMAFiKZEadDYpMSFtYmn7xgN2p5H/FbKijt0NSdqOH9mQ/o5gDCOG4Z4p vPzq+1+sBpkITRe6mnxuMJfQGgSjvtY= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YZW6FvAs; spf=pass (imf30.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719338739; a=rsa-sha256; cv=none; b=00PgNC+2l2N8gAaMgECKS84qRWjhw5JGHZ3H5kgAxUmLEAc0PkQi5SgayVpqdZy8o8Y/Ml Q9p93qzI853DPlvxnUP4EC+JYcgVu3H3L9UxVwD3ys3QFGaXXMgWlks3Y+/VZyRdHb+8uV izcJWittd7j9wB82miIZj/mpnsp+1c0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id C64FACE12C3; Tue, 25 Jun 2024 18:05:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 934D2C32781; Tue, 25 Jun 2024 18:05:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719338747; bh=IuEbQPKkXzrPZK6YAlgDSnlBOl1pA1OTrf32W27fHRY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YZW6FvAsRy1TtK+Ximbxp4cNzEldF+GHKTE6xKDuX6ScVnrZC1O8tsgfOX9GYoVHZ Eqm1ERLccOip5xxxXx6epCVzX+wTcpualFf28d5l4MKI4QRCrCSzencV60QSGuBLOi 7Csl0c8aIY5TAC73Z4Wdb7lqxJ41hE6H1JselBoSUR8yntWrvIXHcjkXmwhX3V7zYr IunlcjQV6pwFuLTJyuegnSY1bux56hSnFNF7v7c2Au875//9QNeWKzB8v0JRYK+fzN il/nYtFa5C4OqrzlY9CqCeCB3aCOwpYpw7cRrZNshhmbRZISGsFW/9yCXEa7HUxtmM OIDlfa3WmwD9Q== 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 4/8] selftests/damon: implement DAMOS tried regions test Date: Tue, 25 Jun 2024 11:05:34 -0700 Message-Id: <20240625180538.73134-5-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240625180538.73134-1-sj@kernel.org> References: <20240625180538.73134-1-sj@kernel.org> MIME-Version: 1.0 X-Stat-Signature: sfhtde1q8kr64xn57ue8i3gwefuczui8 X-Rspam-User: X-Rspamd-Queue-Id: AAB6C80014 X-Rspamd-Server: rspam02 X-HE-Tag: 1719338750-30350 X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qcT3peKGhFquWJXBzg+LsztSuyIr/EdWD/KghGQLyjqRckLYfwrtO3gYlI5jH1HrEVooZ2ZNBEVyhCUCneF63Bbtv2ZZQ5Wrj7NYMxOycZUc/c2jMfBSOczcI/6nmLRjX27eeClYxIkDE/uQICurvrKGG5LZMYE3MV8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000049, 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 a test for DAMOS tried regions command of DAMON sysfs interface. It ensures the expected number of monitoring regions are created using an artificial memory access pattern generator program. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/Makefile | 1 + .../selftests/damon/damos_tried_regions.py | 65 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 tools/testing/selftests/damon/damos_tried_regions.py diff --git a/tools/testing/selftests/damon/Makefile b/tools/testing/selftests/damon/Makefile index 7b972b5cf487..356b4e9a515d 100644 --- a/tools/testing/selftests/damon/Makefile +++ b/tools/testing/selftests/damon/Makefile @@ -13,6 +13,7 @@ TEST_PROGS = debugfs_attrs.sh debugfs_schemes.sh debugfs_target_ids.sh TEST_PROGS += sysfs.sh TEST_PROGS += sysfs_update_schemes_tried_regions_wss_estimation.py TEST_PROGS += damos_quota.py damos_quota_goal.py damos_apply_interval.py +TEST_PROGS += damos_tried_regions.py TEST_PROGS += reclaim.sh lru_sort.sh # regression tests (reproducers of previously found bugs) diff --git a/tools/testing/selftests/damon/damos_tried_regions.py b/tools/testing/selftests/damon/damos_tried_regions.py new file mode 100644 index 000000000000..3b347eb28bd2 --- /dev/null +++ b/tools/testing/selftests/damon/damos_tried_regions.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +import subprocess +import time + +import _damon_sysfs + +def main(): + # repeatedly access even-numbered ones in 14 regions of 10 MiB size + sz_region = 10 * 1024 * 1024 + proc = subprocess.Popen(['./access_memory_even', '14', '%d' % sz_region]) + + # stat every monitored regions + kdamonds = _damon_sysfs.Kdamonds([_damon_sysfs.Kdamond( + contexts=[_damon_sysfs.DamonCtx( + ops='vaddr', + targets=[_damon_sysfs.DamonTarget(pid=proc.pid)], + schemes=[_damon_sysfs.Damos(action='stat', + )] # schemes + )] # contexts + )]) # kdamonds + + err = kdamonds.start() + if err is not None: + proc.terminate() + print('kdamond start failed: %s' % err) + exit(1) + + collected_nr_regions = [] + while proc.poll() is None: + time.sleep(0.1) + err = kdamonds.kdamonds[0].update_schemes_tried_regions() + if err is not None: + proc.terminate() + print('tried regions update failed: %s' % err) + exit(1) + + scheme = kdamonds.kdamonds[0].contexts[0].schemes[0] + if scheme.tried_regions is None: + proc.terminate() + print('tried regions is not collected') + exit(1) + + nr_tried_regions = len(scheme.tried_regions) + if nr_tried_regions <= 0: + proc.terminate() + print('tried regions is not created') + exit(1) + collected_nr_regions.append(nr_tried_regions) + if len(collected_nr_regions) > 10: + break + proc.terminate() + + collected_nr_regions.sort() + sample = collected_nr_regions[4] + print('50-th percentile nr_regions: %d' % sample) + print('expectation (>= 14) is %s' % 'met' if sample >= 14 else 'not met') + if collected_nr_regions[4] < 14: + print('full nr_regions:') + print('\n'.join(collected_nr_regions)) + exit(1) + +if __name__ == '__main__': + main() From patchwork Tue Jun 25 18:05:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13711789 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 5FA9AC3064D for ; Tue, 25 Jun 2024 18:05:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 43E716B009C; Tue, 25 Jun 2024 14:05:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 327766B009E; Tue, 25 Jun 2024 14:05:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 152756B009F; Tue, 25 Jun 2024 14:05:51 -0400 (EDT) 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 E76066B009C for ; Tue, 25 Jun 2024 14:05:50 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 8A11DA2097 for ; Tue, 25 Jun 2024 18:05:50 +0000 (UTC) X-FDA: 82270189260.11.350CFE4 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf28.hostedemail.com (Postfix) with ESMTP id D685FC0005 for ; Tue, 25 Jun 2024 18:05:48 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=io9S9UFU; spf=pass (imf28.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=1719338737; 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=DfegfZhr4USgWzRMX9rKcxHdyxOi3V6ymvitcsExA+s=; b=wfR4bsJcFVlvIBRJZOapc1oEeAfsFup+68xE2x6rKN5aYceAHNSH45xua9B/4yarbL/Raq XRobXAHi04XT1jRMCf0yqR378s+EIrSfA3deIQkiAgRVHbuRAtan1pfjyRjyoTz5w17L4o 3rMQL6I0pZ/NFFYSZY9HvCZcnmsmRBk= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=io9S9UFU; spf=pass (imf28.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719338737; a=rsa-sha256; cv=none; b=6fQoERsTiCmpdmcetipzuOPESWTS9y0u7Az8woEITmoavwyr73mA90xAYwOaCkW5bph084 WcONQ2bKvUGoxt3tCHQ7aMjNEUsWdEAiFFjM0p3XeQ7jCnophRLcivoDNmYRQr+XQ3ufgc BPQ84vHpyzNjQBNUllGXpqCFeToG8Po= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id F109D616DE; Tue, 25 Jun 2024 18:05:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F431C4AF09; Tue, 25 Jun 2024 18:05:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719338747; bh=lD5FdO0GjKR1qAYavsvEm7e4xnZladhl0pTurzLbRRI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=io9S9UFUNH/oAQ5pEtWW2n7hXGpqwhp/fGIEQ4TEsD4moQYtEuxh0rGfSwoF5dlKh 81yPdqkG+YR8pdg/Kq1VN3ax7i2owrWD++iqCGuVwBYMUVg+OInJZTEMAB5xNO3UBg U+mrLmHEBEBv2kSmO6f3OhnpgB4CjL66fiWDyqPkTPScI0gkkgGgA0FL6sXyxYke8/ 1lowHFMMg3OghChgQjYcU4uGdU0Y+ZPMG3a8kJHV7Lmf4cstkUry4Tk8XCZbO8fiMe uUAAzjhMncsMCLLFF7tjPxWQwEupciLGjdlqz3idRAaJ218xGX1pWiyOMmXaQXNaBX l0XLTgdhNjuGg== 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 5/8] selftests/damon/_damon_sysfs: implement kdamonds stop function Date: Tue, 25 Jun 2024 11:05:35 -0700 Message-Id: <20240625180538.73134-6-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240625180538.73134-1-sj@kernel.org> References: <20240625180538.73134-1-sj@kernel.org> MIME-Version: 1.0 X-Stat-Signature: a19b9gjrk47cxgk7axbzs7t94pqoo5cd X-Rspam-User: X-Rspamd-Queue-Id: D685FC0005 X-Rspamd-Server: rspam02 X-HE-Tag: 1719338748-848553 X-HE-Meta: U2FsdGVkX1/ZcKzpbW0+Fc35eaoPb/yVthvEDiMFXj6KKSsrwGjq6eN2Dp/at2GRrrpeZ756NR9cJkZsPeyrjzEMYPmtOzDKI/wwOSEzGubELnJ4yua2Itbtr/7YAs/BvQ4EFn0hy92+XS8ME2q1d3nxNZH8AAUJY9cZiqzLxD0AmO0GbnPgKq3A1AL1NrYlXvhfz0FpJ1c8bZjZjstb0DhofGgVO0gUtlLNU98knYM+WPycYW8iwqx/d/7BlBQ2Qy3L0mUzuK21T7kHlayONWVX7OG2mStGyW6zw+oRtc48VXouJFajC7kYMMi42il//VOYtBeHdGj31tcw5svXXSK5DJOKZSNOMmVulQmFZZj46HKRuvN2ez73qkzyfziaAYvff7SJn6OOVQv2Cjb5QYCTsnUzxLNklvcf9ef4Cng4xNkA1KVtHdyUkZYG9bB3VeBGnw2xz9Cs7USRUpSPg50ZfuQn+bCArBdO6Bmxu5w2O5bjyTMouIMniZ1z+8bB1riQ281SUinL530Ux+dGNk2CLsTfNA8GWjNiMpJ3cKoEXjW7+iD93vRRkzCihNIfFYfM6cIdWbYEJo9YiVIxtxEq1BdwqdHNq4Y5LItVL3LUTW6+hKcoIvirUdIa+wRQ7Q+qcvKoE0HAngfVPsVFUq2mnMDDT4shRpL9WATEsMaSAAPMDBoZyZ8KINi2NGkAxwPognQ8DwnsbzmfFcygqdQ+mSGJByUwuREcjdbZ+XmwVgNSHtmU4wVBR/ZjiMebh8iChFv76BwDogdMEqJmPAabe8BDEqqAjxBtq3Fa82pNFVeE+9QNFaVJSf80O9UJ96sU5FOg1x2lFfR6UaMf4LsqCHlUIRV/OkZH7jKPI8z0Nj+M7EjuluOa6o+Yg3yhhsN48qckOWhFKKcSw4VIB+XQal1/nvJJwt8UbsKL0yOtxMU+yrBwTMxYi5uNOjFVcwW0lbjfyUcLlhkfR/N xV2p4Wm+ qN/Zc9nQbIx/umXNmj6OmGY2DzqWvXe/tiY0BArXkWyu57k0nGxWF6856/DmK+SfcQ3wbd6IGDi9nGsUK8D8+k7x/Je70Ma5rc++HuM2yy7c75TQiJXyv3ogxsABV/Oy+7BRb1lNA8hBUNMP8U1JO18JxWca/CkqIHB8EizqIhN5uouRorr4f7YNJoxjgNgthD8XEG2k10d4Jinh7QTUCLkgKpEKYOGyGTbOKEYz+v5I6G4MgTuakJRfJl87YuefRLuz39UKzsrCxf66wHzDYI0ydJiFdVWhrjvUd 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 DAMON stop function on the test-purpose DAMON sysfs interface wrapper Python module, _damon_sysfs.py. This feature will be used by future DAMON tests that need to start/stop DAMON multiple times. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/_damon_sysfs.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/testing/selftests/damon/_damon_sysfs.py b/tools/testing/selftests/damon/_damon_sysfs.py index f975742f29b3..17352b9d204d 100644 --- a/tools/testing/selftests/damon/_damon_sysfs.py +++ b/tools/testing/selftests/damon/_damon_sysfs.py @@ -406,6 +406,10 @@ class Kdamond: err = write_file(os.path.join(self.sysfs_dir(), 'state'), 'on') return err + def stop(self): + err = write_file(os.path.join(self.sysfs_dir(), 'state'), 'off') + return err + def update_schemes_tried_regions(self): err = write_file(os.path.join(self.sysfs_dir(), 'state'), 'update_schemes_tried_regions') @@ -511,3 +515,10 @@ class Kdamonds: if err is not None: return err return None + + def stop(self): + for kdamond in self.kdamonds: + err = kdamond.stop() + if err is not None: + return err + return None From patchwork Tue Jun 25 18:05:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13711790 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 46B18C2BBCA for ; Tue, 25 Jun 2024 18:05:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EC8086B009E; Tue, 25 Jun 2024 14:05:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E71066B009F; Tue, 25 Jun 2024 14:05:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C774C6B00A1; Tue, 25 Jun 2024 14:05:51 -0400 (EDT) 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 A3B7E6B009F for ; Tue, 25 Jun 2024 14:05:51 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 55844160469 for ; Tue, 25 Jun 2024 18:05:51 +0000 (UTC) X-FDA: 82270189302.16.EE17D3F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id 76258140021 for ; Tue, 25 Jun 2024 18:05:49 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=CkQxuGZQ; spf=pass (imf09.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=1719338729; 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=ToGiGzJSGLsESutubIhiPMJBkNnFffebkP2gqfJ3X7g=; b=Vl/jWTuElXcUpPha3Te0cdwGskBOXYF3KxFe71K4cFdRPuz0DZ4yM8jM7X/p0A8AfZDrQn YVMVGDO9VFRMjXW5ta3d5NNFpGHGkNYQa2lfzWKTy5ljBOWwPvW8FA5vRzWd1ljNBoJK7Y +/4jAUuA6eeXvxPQrkKtAezje/8ZBvE= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=CkQxuGZQ; spf=pass (imf09.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719338729; a=rsa-sha256; cv=none; b=Aic/7FKBXfPO7heBgwKCy1VwbD3sQ222codc79V5snMt+8EHYvUvap6Cb4HeFBcHS2JJpD Hc6P78cL0VkeOyNlli860u69Mv4o4+M92WswbEv2kN+VuVSmQnKvef3KGRfrdP1CogTCL5 IY10mbC4ggCV4B629Ejb+wuxPngtjSI= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id AB2E261730; Tue, 25 Jun 2024 18:05:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05CABC4AF0B; Tue, 25 Jun 2024 18:05:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719338748; bh=NVtILSH+9XYglOUzDKTB4NeWGCqUXF9j4Ar1OAT5e/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CkQxuGZQDXDSFVVkxd+cWTiZYH9I8X/TYlIjNbrGHDCeUjCwfc99G2TAMubyPKLvE Ttbt8FSCaARYyIm2t69Cc620QeD8bOnvdvMoQaKIrG++rqPy9RgvXqPkvOcaA29ECE qQLYRrC545HJC3vFtMGhbLcrAgJG0bOYNcS+uUmEtO/2CKjZxiHesf8Ni8g+NUeQba r4A4E2J3oZhGyQbU6XX2X2jRn3KK/GPF3fxXzorBTTMJX5vbPDjqkve/6oXz28464T 1BRM/pV6sXNzmGMUBXXbF2gA5mxQUBbswUOoU7b4Dlj5iLuYH5OOwgKBvwp8ye/AsO IIUNQcghvm0Jg== 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 6/8] selftests/damon: implement test for min/max_nr_regions Date: Tue, 25 Jun 2024 11:05:36 -0700 Message-Id: <20240625180538.73134-7-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240625180538.73134-1-sj@kernel.org> References: <20240625180538.73134-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 76258140021 X-Stat-Signature: wzeg6gibq6xj6gd4uzqaha9bm5rsrjja X-Rspam-User: X-HE-Tag: 1719338749-46545 X-HE-Meta: U2FsdGVkX18h1ha+8LzesCg+fSbMrHfWt8vge/qPejnzeNtD53Sc/3c2pOjHJbQ+/uR3IVvDU3rRBo9aVNX6Vza5gMvKCK6GYfCDFHJjfowf+jhMso+lRNkdn7vIEye7BEqVpQ+ckrAYKKNmOhPW3ZCoytpv8KmYRQHfEVBbALQx43bRkHTZY04S7SlC2IAxtb45wAmXhuiNd3UFJF5qYM/QI8Ti3+Zq8zEhXbHHCnXRvroEZ/B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: 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 a kselftest for DAMON's {min,max}_nr_regions' parameters. The test ensures both the minimum and the maximum number of regions limit is respected even if the workload's real number of regions is less than the minimum or larger than the maximum limits. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/Makefile | 2 +- .../selftests/damon/damon_nr_regions.py | 85 +++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/damon/damon_nr_regions.py diff --git a/tools/testing/selftests/damon/Makefile b/tools/testing/selftests/damon/Makefile index 356b4e9a515d..1e2e98cc809d 100644 --- a/tools/testing/selftests/damon/Makefile +++ b/tools/testing/selftests/damon/Makefile @@ -13,7 +13,7 @@ TEST_PROGS = debugfs_attrs.sh debugfs_schemes.sh debugfs_target_ids.sh TEST_PROGS += sysfs.sh TEST_PROGS += sysfs_update_schemes_tried_regions_wss_estimation.py TEST_PROGS += damos_quota.py damos_quota_goal.py damos_apply_interval.py -TEST_PROGS += damos_tried_regions.py +TEST_PROGS += damos_tried_regions.py damon_nr_regions.py TEST_PROGS += reclaim.sh lru_sort.sh # regression tests (reproducers of previously found bugs) diff --git a/tools/testing/selftests/damon/damon_nr_regions.py b/tools/testing/selftests/damon/damon_nr_regions.py new file mode 100644 index 000000000000..dd2735923c59 --- /dev/null +++ b/tools/testing/selftests/damon/damon_nr_regions.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +import subprocess +import time + +import _damon_sysfs + +def test_nr_regions(real_nr_regions, min_nr_regions, max_nr_regions): + ''' + Create process of the given 'real_nr_regions' regions, monitor it using + DAMON with given '{min,max}_nr_regions' monitoring parameter. + + Exit with non-zero return code if the given {min,max}_nr_regions is not + kept. + ''' + sz_region = 10 * 1024 * 1024 + proc = subprocess.Popen(['./access_memory_even', '%d' % real_nr_regions, + '%d' % sz_region]) + + # stat every monitored regions + kdamonds = _damon_sysfs.Kdamonds([_damon_sysfs.Kdamond( + contexts=[_damon_sysfs.DamonCtx( + monitoring_attrs=_damon_sysfs.DamonAttrs( + min_nr_regions=min_nr_regions, + max_nr_regions=max_nr_regions), + ops='vaddr', + targets=[_damon_sysfs.DamonTarget(pid=proc.pid)], + schemes=[_damon_sysfs.Damos(action='stat', + )] # schemes + )] # contexts + )]) # kdamonds + + err = kdamonds.start() + if err is not None: + proc.terminate() + print('kdamond start failed: %s' % err) + exit(1) + + collected_nr_regions = [] + while proc.poll() is None: + time.sleep(0.1) + err = kdamonds.kdamonds[0].update_schemes_tried_regions() + if err is not None: + proc.terminate() + print('tried regions update failed: %s' % err) + exit(1) + + scheme = kdamonds.kdamonds[0].contexts[0].schemes[0] + if scheme.tried_regions is None: + proc.terminate() + print('tried regions is not collected') + exit(1) + + nr_tried_regions = len(scheme.tried_regions) + if nr_tried_regions <= 0: + proc.terminate() + print('tried regions is not created') + exit(1) + collected_nr_regions.append(nr_tried_regions) + if len(collected_nr_regions) > 10: + break + proc.terminate() + kdamonds.stop() + + test_name = 'nr_regions test with %d/%d/%d real/min/max nr_regions' % ( + real_nr_regions, min_nr_regions, max_nr_regions) + if (collected_nr_regions[0] < min_nr_regions or + collected_nr_regions[-1] > max_nr_regions): + print('fail %s' % test_name) + print('number of regions that collected are:') + for nr in collected_nr_regions: + print(nr) + exit(1) + print('pass %s ' % test_name) + +def main(): + # test min_nr_regions larger than real nr regions + test_nr_regions(10, 20, 100) + + # test max_nr_regions smaller than real nr regions + test_nr_regions(15, 3, 10) + +if __name__ == '__main__': + main() From patchwork Tue Jun 25 18:05:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13711792 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 3D0BCC2BBCA for ; Tue, 25 Jun 2024 18:06:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B40F76B00A1; Tue, 25 Jun 2024 14:05:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AF1656B00A4; Tue, 25 Jun 2024 14:05:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 80A036B00A2; Tue, 25 Jun 2024 14:05:52 -0400 (EDT) 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 5F8CE6B00A0 for ; Tue, 25 Jun 2024 14:05:52 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 0C0E2A20A4 for ; Tue, 25 Jun 2024 18:05:52 +0000 (UTC) X-FDA: 82270189344.23.6216671 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf05.hostedemail.com (Postfix) with ESMTP id 6277C100030 for ; Tue, 25 Jun 2024 18:05:50 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="YJX/VNho"; spf=pass (imf05.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719338742; a=rsa-sha256; cv=none; b=estX8/F64wgb2ob0zkHsTf7aLm84oo8lBeLr7L1RE9YP0KpZ2Iidvt3hvsOvhlIfiB41z9 uScZJ0try0wJva+U3q8eOE8N8SM73IjdnVZmrJmLEdQY6Js1w9robCpc0t+YbIZOqdWRdv r/3Ko2y2yrciHMlrBqaUV6c6Rd3g+T8= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="YJX/VNho"; spf=pass (imf05.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=1719338742; 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=wDqXlKd+2c7qYvjpVgVXcj338jA6AU6Vdiwq6k7vHxY=; b=b2MEtrmZaAuXElcFxYIORhn/eyZwp5drgvpJeduXbSpCWnfULIjXp/7cJwTCCmA7cdipHC r/cFzDUlUQ4987XnKiNLqQyN6m8fBcdjQGoWa22B8kud2RrA495u3BYfFoaqZx/1TaMODZ a1C2yQIqmThdAf8/wgXeJbY0CzfZTXk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6394C616DA; Tue, 25 Jun 2024 18:05:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3D20C4AF0D; Tue, 25 Jun 2024 18:05:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719338749; bh=gJIZChP/stfR9DmaAxQLH0gVjnmXTejsJJ91eVHAK8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YJX/VNhoKPVAhVJq94R8nCXyATG+V3v1HHEVqCWWYENRsI8vidfdlUx0uJE/rbRXU CAOT9SwrvkvU2hfYyWb3prqwvbYJk9AXHcSvhoKxQMkx2rkCe4dz7Z+Y+yvRY+K3XH Q/DiY6lgayFm5gtQqAZ7WLu0JE1vBwmEmHDV7IHUvHmm+RzJDENGNi86l8M8QFIaNH +SrafYC6A892YXUxjZy0vhqQ8lAQXOCgor4LvUVNoeVU949S/rU0OqzlHVu1oSJ5L5 C9iKcuN40JhoVBFx/BDVzmeSAphRqMWG58z51QK7OwLFwynp1A3Wz1q+ncyP0pezzl 8nNEVKL/9SIbg== 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 7/8] _damon_sysfs: implement commit() for online parameters update Date: Tue, 25 Jun 2024 11:05:37 -0700 Message-Id: <20240625180538.73134-8-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240625180538.73134-1-sj@kernel.org> References: <20240625180538.73134-1-sj@kernel.org> MIME-Version: 1.0 X-Stat-Signature: pcto9e7gm8h4p1qkxci3odtro514bbwp X-Rspamd-Queue-Id: 6277C100030 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1719338750-118639 X-HE-Meta: U2FsdGVkX18uS3G/eC8wDpAAwEvm6D9n04snre/MdvLjIXhYZv90rCwqkXJrIHDO4U8BeyPR3Vrd/HCraNLh3iUGq6dbi9rqAHyWBWgE4Z9YlUCCdIMyiBUggHTzvDv6A4G096S/5NJmbZIqlir2RvHuaoinSFTIXsoKDriTj7319GvN9d9/f021L+PWuQYorEursDdZZmknb+hy8vBotFCgNb6fcKNmTNB6paxfH8QYSnHDx+q49/TaAFc2t/Z46kCyaRkBIpxDkvLWD0g0gqpZ5rfveSrKoYFlr82R9S+i0qLJw2RonPuIrOwwTYsg6h0G0FdvR3a1DcG2hHDnjsHkAeUBImeKgqD5/ztHU+etT74m+2rbEyAS1m7t3/MKkKRvidrxK3Cd/FmWJyKPBjRQr8En/ArJU+IEEGfbRfy469IQ6g/xr1E3vUHoTEnAWNcaGVYF9PDMSn2Mcam3Wd9627GklwrwyHGRtNPrnjtmHXSBvelMRI7bkUDpAo7CYhNHdDaR6wdDaF92inuUNuWcoGvwlSFAPa44CWFhTwQ8YDd/c762sDJXAgv1hDZQ4IndkILNmtnW+bDJb72St2eLARYFdpqLKBnTQRwAT0HZDYPYoyaVn3fv9L8inXaTlYvGFNdCWnK++7ThOOUSipR5N2bNMmMAtfoQfR7Rqok40yW1tZpWXRpgM5/Ei1LQM8mwX5mL7n90Dz7LZJs4sD6jvuEUNvljYVwXIxFroIGrt5HVviDZh3mgFbFQI5+yJXQZQZzeqdCJrCeBDsWs7BlPi1Nf7E6QsbHy2rF7yPYMfte6D8Iw6Q44NZ26yM911wtpTir92A/FeSIlU0waWcdbkznQVXP2Wj3Ags8/oqesVGtqYZMJ6n4W0TeSgCqsgBElSQtmIV7GT7U7533omW25AMn54nA5tkOoe4rU4sQyzvFYO3wa95Y+FrRclzEQnoMk5mJbifKAgSbDKV2 pdo8itz1 PVIxCW37srbd4anUnwKSEw1C/TnrlmhOcU0jVs5Gtmd31hIny8PSFt7gZPgC/AEaMEC4HuNFglcTsgffG65py+e7lMdsNfZ9xvLu+Rlw4V5yMyV4QYNtuMYAFkESdz0HKUMVZu06nDv7EqGfmsrGXcbKHDTrdsZd/q+61srFYuEtH2CoEfWqUfhyWUDsCAvhK+pjtOFIFodKunumZ9k1DN5ou153N2bcorXnQ+g86bWNmwR68NmO25w276vbidYS/0Azuv4uOCnOn380BCXn7Q/NVb7jfqsLd0u2f 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: Users can update DAMON parameters while it is running, using 'commit' DAMON sysfs interface command. For testing the feature in future tests, implement a function for doing that on the test-purpose DAMON sysfs interface wrapper Python module. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/_damon_sysfs.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tools/testing/selftests/damon/_damon_sysfs.py b/tools/testing/selftests/damon/_damon_sysfs.py index 17352b9d204d..6e136dc3df19 100644 --- a/tools/testing/selftests/damon/_damon_sysfs.py +++ b/tools/testing/selftests/damon/_damon_sysfs.py @@ -481,6 +481,25 @@ class Kdamond: goal.effective_bytes = int(content) return None + def commit(self): + nr_contexts_file = os.path.join(self.sysfs_dir(), + 'contexts', 'nr_contexts') + content, err = read_file(nr_contexts_file) + if err is not None: + return err + if int(content) != len(self.contexts): + err = write_file(nr_contexts_file, '%d' % len(self.contexts)) + if err is not None: + return err + + for context in self.contexts: + err = context.stage() + if err is not None: + return err + err = write_file(os.path.join(self.sysfs_dir(), 'state'), 'commit') + return err + + def commit_schemes_quota_goals(self): for context in self.contexts: for scheme in context.schemes: From patchwork Tue Jun 25 18:05:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13711793 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 6B999C3064D for ; Tue, 25 Jun 2024 18:06:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 094AB6B00A2; Tue, 25 Jun 2024 14:05:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F360D6B00A3; Tue, 25 Jun 2024 14:05:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D84CC6B00A5; Tue, 25 Jun 2024 14:05:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A37FB6B00A3 for ; Tue, 25 Jun 2024 14:05:52 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 5EA7DC04DE for ; Tue, 25 Jun 2024 18:05:52 +0000 (UTC) X-FDA: 82270189344.21.2FFCEAB Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf28.hostedemail.com (Postfix) with ESMTP id 92A80C0005 for ; Tue, 25 Jun 2024 18:05:50 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=TTmsSt1L; spf=pass (imf28.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=1719338739; 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=YTiFptegXC0rppC9bHqrhYBnewbj0+nicoYYTPan1WQ=; b=r98io+Q4ZycCacXPLB6Pd0GTOTmTyOc26wH/Kc5s/hsyYAEIA40M0DfJI++egsE/pC1a65 8jujLZ+O6S4rNpBkafmfA0qU+IlBPkut49RsiHGx5vUPdILmtBS/3KALuQdQqvwpvNPFR6 JVepcTS449Tqcmh4wSf/E/AwMIH+c8k= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=TTmsSt1L; spf=pass (imf28.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719338739; a=rsa-sha256; cv=none; b=QzOlAqHhxRUagFInYNNpUKQiXJD1+hWQj8iLUZBiazWYRJ6RTOLepVqqKSgt7HeMoNOUlo kOd1xCAfJysckZyS2LtwIVEzM4UBkz//ToODtXgtHhF2j8c8j5UfqkwJu/OmIaTTmB+ju3 mhpb+z4F2oce05/zydfvHtcWSvKuao4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 1B90561741; Tue, 25 Jun 2024 18:05:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6AE08C4AF13; Tue, 25 Jun 2024 18:05:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719338749; bh=8dhvoCKICij/0wQGSNgn0SXQ/QZt5ONQbTkFqj9oMd4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TTmsSt1LplYj2gx75lsu0LsLjYr7zpzivWHZeftrLD0ikOQkOY2ldifr5MyonkG9z Uf45WeUIRwFWXiAVVEGIFR5veoTR16qDvL/6I/kdKd4CfTN0aME3VwZCxrqR6zHfAG /1Od2Xe0EHh3kzxZQlBtkIS4/0YW6VU6XoVvZDZLayp0Zhz1s17+PQxhTTMesi+EQp 0W+jIkvNvTobeeMDy23Lq3WZTQnlWOzECqfODDegNv6ji7a+UqEYbzXiGjtwro6t/1 O9AD4ZwQUmrF7MsdNc9208Tb6RHx8CjZuV/eFPf8lacpyPrKP1TWqkO2NyEv5YTbdq 1WUgDBxyxdcSA== 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 8/8] selftests/damon/damon_nr_regions: test online-tuned max_nr_regions Date: Tue, 25 Jun 2024 11:05:38 -0700 Message-Id: <20240625180538.73134-9-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240625180538.73134-1-sj@kernel.org> References: <20240625180538.73134-1-sj@kernel.org> MIME-Version: 1.0 X-Stat-Signature: 3t1rje4m6zg8e9xrnehyiyh4b6mdppcr X-Rspam-User: X-Rspamd-Queue-Id: 92A80C0005 X-Rspamd-Server: rspam02 X-HE-Tag: 1719338750-588961 X-HE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Am8K1JcceDRRjFHkaNl3nICWKpezGRZQz8xpD6qsqHxXFVYqH6hloQe2UfHGxvp5OsSk/+HZ/FdRUXysiXeV0NTG4oDd459/u1UwsOhKcRKrbwBBf64PJtK1ydo/q3TYK+PzhxROievtxceMR6oGzJNJq/pEmlXBW7QG7tH98t73QDdeFDdrzFATqSxWH4wanD8uNExUQ98KgXuOMZporuu9ZHt+wzskOhIh9YhrkFqsnjqLqqN 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: User could update max_nr_regions parameter while DAMON is running to a value that smaller than the current number of regions that DAMON is seeing. Such update could be done for reducing the monitoring overhead. In the case, DAMON should merge regions aggressively more than normal situation to ensure the new limit is successfully applied. Implement a kselftest to ensure that. Signed-off-by: SeongJae Park --- .../selftests/damon/damon_nr_regions.py | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tools/testing/selftests/damon/damon_nr_regions.py b/tools/testing/selftests/damon/damon_nr_regions.py index dd2735923c59..2e8a74aff543 100644 --- a/tools/testing/selftests/damon/damon_nr_regions.py +++ b/tools/testing/selftests/damon/damon_nr_regions.py @@ -81,5 +81,65 @@ def main(): # test max_nr_regions smaller than real nr regions test_nr_regions(15, 3, 10) + # test online-tuned max_nr_regions that smaller than real nr regions + sz_region = 10 * 1024 * 1024 + proc = subprocess.Popen(['./access_memory_even', '14', '%d' % sz_region]) + + # stat every monitored regions + kdamonds = _damon_sysfs.Kdamonds([_damon_sysfs.Kdamond( + contexts=[_damon_sysfs.DamonCtx( + monitoring_attrs=_damon_sysfs.DamonAttrs( + min_nr_regions=10, max_nr_regions=1000), + ops='vaddr', + targets=[_damon_sysfs.DamonTarget(pid=proc.pid)], + schemes=[_damon_sysfs.Damos(action='stat', + )] # schemes + )] # contexts + )]) # kdamonds + + err = kdamonds.start() + if err is not None: + proc.terminate() + print('kdamond start failed: %s' % err) + exit(1) + + # wait until the real regions are found + time.sleep(3) + + attrs = kdamonds.kdamonds[0].contexts[0].monitoring_attrs + attrs.min_nr_regions = 3 + attrs.max_nr_regions = 7 + err = kdamonds.kdamonds[0].commit() + if err is not None: + proc.terminate() + print('commit failed: %s' % err) + exit(1) + # wait for next merge operation is executed + time.sleep(0.3) + + err = kdamonds.kdamonds[0].update_schemes_tried_regions() + if err is not None: + proc.terminate() + print('tried regions update failed: %s' % err) + exit(1) + + scheme = kdamonds.kdamonds[0].contexts[0].schemes[0] + if scheme.tried_regions is None: + proc.terminate() + print('tried regions is not collected') + exit(1) + + nr_tried_regions = len(scheme.tried_regions) + if nr_tried_regions <= 0: + proc.terminate() + print('tried regions is not created') + exit(1) + proc.terminate() + + if nr_tried_regions > 7: + print('fail online-tuned max_nr_regions: %d > 7' % nr_tried_regions) + exit(1) + print('pass online-tuned max_nr_regions') + if __name__ == '__main__': main()