From patchwork Wed Feb 7 20:31:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13549057 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 EC238C4828D for ; Wed, 7 Feb 2024 20:32:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 45FC36B0085; Wed, 7 Feb 2024 15:31:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A8056B008A; Wed, 7 Feb 2024 15:31:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 00F306B0088; Wed, 7 Feb 2024 15:31:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D50FE6B0087 for ; Wed, 7 Feb 2024 15:31:50 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A9C9E1A0924 for ; Wed, 7 Feb 2024 20:31:50 +0000 (UTC) X-FDA: 81766153980.29.2BD358F Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf28.hostedemail.com (Postfix) with ESMTP id 44830C001F for ; Wed, 7 Feb 2024 20:31:46 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lx8mnNCB; spf=pass (imf28.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=1707337908; 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=e1UvP10+60uT60vfwuQyHfpn7s5IoP2FL/alemxKsK4=; b=Uiz/MXoE/tee0U8Uf/mn1wZc+jo2Y4ovMlUoQfNlY+jFKmygswpwhfDhlaTKCLyj20YVZG QzTmjG6Htrt+xNvqGzt1xS2tOGLWK4jfAkj7bKdHPXTgp3TqY2RMbvIqDzjBpYDWTDcfql Pwt/1D8+U4WGLUWB7lR/GxzPwLscAEM= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lx8mnNCB; spf=pass (imf28.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=1707337908; a=rsa-sha256; cv=none; b=KxO6/xtOYY7ff4rA7lDDq4rKLSiRp7rW2D64U4i8VD2jBo8Cx0n4vpKHeLG2wV7j3iWJwf Tut5mNrsEF/2BQ847AdlNOR4zyo59gC1t+or1L46uZ7rpCNBKkT9Ksm4QC1E0uLlF5BcSa lCCUDjXz+ZXpujGX7fdZzb7MHFa/ajY= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 76477CE1AFA; Wed, 7 Feb 2024 20:31:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27297C43390; Wed, 7 Feb 2024 20:31:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707337901; bh=JQERS+AD7eJcXPmEIi+Gcjav4/4TJSgTRdHhSGiTeC0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lx8mnNCB3FWWVgO2+jRkTgucZGTLeSzoBIZ/EFuBxNFxGuPQ0D8MFrtTw7iwrE1Na aFQEjvUUK4Yev4Dy6G++TsGO2kIx4pcqN7D3BLsUKIALU3zTZalx1xNnZcvJZPrvsF H8gT8OKhTA4A5tPW6EPXK+ZEpjk546ZmS104vhzh4148PSKRj4FOzL6qNZZDwX/Vyh kMtuD1aZQm/PWZwzbxHibyvmi6bSLIQiPQhoQniGkMI61KXBripkvkHUukfFQGYqvm AlXLfX0IgWrj5f4KRCZMdu1nEmvG5U82kPY3ZAZt+zPUu8QkR+FMe1jcOaIyNuRbYm +QowLnrkH/NMQ== 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/_damon_sysfs: support DAMOS quota Date: Wed, 7 Feb 2024 12:31:27 -0800 Message-Id: <20240207203134.69976-2-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240207203134.69976-1-sj@kernel.org> References: <20240207203134.69976-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 44830C001F X-Rspam-User: X-Stat-Signature: 8a1eky3cg9m88tpm7gar9t5is5quk4th X-Rspamd-Server: rspam01 X-HE-Tag: 1707337906-852717 X-HE-Meta: U2FsdGVkX19W7dGh7UBpSJoUPSmuhtksui2vdfDnv/9VBedoplXCFIG0juUePfa6hdCwktDssOzhMGFado90t353eYWcR89RrdnPrCuf8uhhvQEmvHQPMK1KNTm6UsUaVdHsxrqDUYCcujQQTJ9NYJn7YEA9XKyMgRBNHQNo+QEWeneiASkWj/Teh2TscQNADyIZ1OdlV8ATSDmBlvswcRTn5HAJhEdt9KHHq78EIA2aSvQcE9e+y0qIxKoa6jWyK3yc5q8Kkk3qnyRyHrjwHeGUQ0xrQLHXNrfLQGAn0yMSh4qftZHYSYbXqSJCU4LiSBrJ0eEkGkbxQ1NkW4HY6qaPijdGsfnS3Ox7z90HlAzF9zsw91UsjIbmY79Ed2eMP+IV8LvC24IpnasxNZbUg9UyoychvhyVeGAOjhrWPRHtYKYLhBgvVDQGd0OTf/MckMcG8iqhzeIMUP31sciw7dkN/iUZxTHjDcPMEocJ9Q8u7Al/e3fFonaI9gex4IDpQBsLLH+uxsu8BNogXrRWR3N2ZeQmJROQm8VeAmZtdYB1oLBkeZCLdta6Gy72T5grp712/q66+CY21+dfLFfnqusEL6uWOOrHEYC9xPS9RGV0mEm7Lrd9cBIG8tWKnfggzlfVCleLHfvGJP2WJ2vOSj6br4C4laBc1fYKFS6lxvtXSbg8+i0mESHfq17mH7lEOhVN9V0cPspzBi/QW8c3p6dBszsx6PyTlYe52n3RSbu8tpsh7ODVHnJqe4A36T6Y7+YDkZWNvIfbnvhOW5QHfC2TdPUXO26/sZvqm+yqqp1p158/Nl+FjidQe2MItDEYgDiQdG3yIbVBfFt794co3x26v4IVmjItX9v4MzDS9fEzEy6PG4PoDbF1ELwF74thK1tWaCVaX/atU3pJnyJql+1H0+ahaVmwf62w+TJT6Cpv6YKC0WXt06/sacINUmXSYJzhFF1jUuS7alAEb6F ks2DXcGT hybmMjTJwjj5fsAYmYbGPyZbuZAMOAiORh2QHFbDDxyszGcFwjrc5OzLFDqlr6wVQUV3+KjpzFMVQT81GTpCvP6ol/YJVJmtDAFOB+NfK9KEisOQVY2T8mG/9Wyf/vi4FvhxWUa6Fo6wsfSIoOUZvLf1c9NJrZdjQ6LM0p72Sjjlq0Cme3CZq4dKngP3YVPMinkARxh4mM4IXtsyrqy+VlS4wbN1jqDLa3d8oYbkzD7vGEabw26hvuiPTLAiWCI9nk3ip32jp2qt4m0j71mPEpb1d+A== 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: Update the test-purpose DAMON sysfs control Python module to support DAMOS quota. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/_damon_sysfs.py | 42 +++++++++++++++---- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/damon/_damon_sysfs.py b/tools/testing/selftests/damon/_damon_sysfs.py index e98cf4b6a4b7..b4f6e385c564 100644 --- a/tools/testing/selftests/damon/_damon_sysfs.py +++ b/tools/testing/selftests/damon/_damon_sysfs.py @@ -70,18 +70,48 @@ class DamosAccessPattern: if err != None: return err +class DamosQuota: + sz = None # size quota, in bytes + ms = None # time quota + reset_interval_ms = None # quota reset interval + scheme = None # owner scheme + + def __init__(self, sz=0, ms=0, reset_interval_ms=0): + self.sz = sz + self.ms = ms + self.reset_interval_ms = reset_interval_ms + + def sysfs_dir(self): + return os.path.join(self.scheme.sysfs_dir(), 'quotas') + + def stage(self): + err = write_file(os.path.join(self.sysfs_dir(), 'bytes'), self.sz) + if err != None: + return err + err = write_file(os.path.join(self.sysfs_dir(), 'ms'), self.ms) + if err != None: + return err + err = write_file(os.path.join(self.sysfs_dir(), 'reset_interval_ms'), + self.reset_interval_ms) + if err != None: + return err + class Damos: action = None access_pattern = None - # todo: Support quotas, watermarks, stats, tried_regions + quota = None + # todo: Support watermarks, stats, tried_regions idx = None context = None tried_bytes = None - def __init__(self, action='stat', access_pattern=DamosAccessPattern()): + def __init__(self, action='stat', access_pattern=DamosAccessPattern(), + quota=DamosQuota()): self.action = action self.access_pattern = access_pattern self.access_pattern.scheme = self + self.quota = quota + self.quota.scheme = self def sysfs_dir(self): return os.path.join( @@ -94,13 +124,7 @@ class Damos: 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') + err = self.quota.stage() if err != None: return err From patchwork Wed Feb 7 20:31:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13549051 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 4BB8DC4829A for ; Wed, 7 Feb 2024 20:31:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A98366B0075; Wed, 7 Feb 2024 15:31:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D23C6B007D; Wed, 7 Feb 2024 15:31:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 786246B007E; Wed, 7 Feb 2024 15:31:45 -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 6B7E26B0075 for ; Wed, 7 Feb 2024 15:31:45 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4D17D1602BD for ; Wed, 7 Feb 2024 20:31:45 +0000 (UTC) X-FDA: 81766153770.24.3448810 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf20.hostedemail.com (Postfix) with ESMTP id 9745D1C000D for ; Wed, 7 Feb 2024 20:31:43 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=XdziAUn9; 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=1707337903; 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=z0T7CeVYOD9GKKEfBy3IV150lcFUebiMsZa/LbzzEfc=; b=qk5wiluDLllBU1Ybd2B4BGxE6Jj+esOaSYadO2sGVPz2Ey22L6VBmmqGeEPRCb44Z7yyj/ s3e77rJ0goByMvp49OT+EPCkEh1SablaLs6WwsNW366X/b/Wjr3drVEX+W36riNYMrrgv2 wDMpxQ0hFD8uynGEZ0IPj5QgJY/DZyA= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=XdziAUn9; 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=1707337903; a=rsa-sha256; cv=none; b=25bUbkPqufYBsLZI0EHpCd/MEWUQlbd+X9CsAbKaPnQpZMFVn+63/AVMB8S3zxc0INEa0V Uy0sUvL6IZDFRJSekx6bNFC0PYFJJieRl8XKjGnq89yjtr7fUlDwgDpRYRHpNSjiQzXa79 3dm4vBmt+ip4wrM8eIRGW5SrvBT3vi0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id BA2BB61AA5; Wed, 7 Feb 2024 20:31:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA011C433A6; Wed, 7 Feb 2024 20:31:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707337902; bh=SwdeOXExaKQGPJVJ2NaT/lednGj9CW7yt27zl0ck87s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XdziAUn989qZYGouOke5VJZROLyvwJMYpwiWYmq66BUEXenv4+YEFtDUWAJ+A9e46 4RcITM/aROpBnV+7byqwfQVSsuyZPtFLLVl+f8ctcCaXnoDBxj77Kj7brTuY7MxQzf 6NO9ac8gHvUjq74gTlJ4q47izd+Hf6ebBXti6tL+WXPNCl37Qsm8WS036hCLnt6xHx 4B0sBDrpLG1W2uOj69vF8f5540kveMiYpR8ER1drvalND7Cz/HlPbut0+TCVD/d7yH EAs7LM4X6EwP+4OXCl44FY2ZUcPhdn5aGcueatWZCkqpFk+6X66NXx0kXHlRCjKbgK O5Yym670dAtVA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Shuah Khan , damon@lists.linux.dev, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/8] selftests/damon/_damon_sysfs: support DAMOS stats Date: Wed, 7 Feb 2024 12:31:28 -0800 Message-Id: <20240207203134.69976-3-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240207203134.69976-1-sj@kernel.org> References: <20240207203134.69976-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 9745D1C000D X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: nipt7szmf653xdegh9koypsd1jfh5gqa X-HE-Tag: 1707337903-323330 X-HE-Meta: U2FsdGVkX1/PS+dv52P0nQaKNDzpSSQOcRMFqpoabSMLqSP9Hv7X2VDObeqmz7dNKGvEYTW9JvvFIIAn84TDfa5uFNKban9nBwrH/jP4c6gBolc9PMKNSDeToYKazWtDtAx677Tpd/btowIvUu5+13l6cnAJTP3/+EXwBkuYKUNM0qpNDTuMh37Pzv0G6L5qkfKqqlWLCw7z5n1kMecXyYdWc7TxZV86x5xkC/W2lkbMFrD2RCFshlHUczrnlYd3WuznMpF6NWHV+9OYcrcaKkmg0Bp0lFTb4rA6I+RorOkGo0XD8bNn9JAVJlDOUKAcqNRmOGMgJWbHiY/eInwKasbDWKMw7iBknDMss/tKGbyESiLM1cwynBXTHPpzyPATTgk06HtFqJRN9DmzvCjKzX5u2pGmrAAJzAbP9R76ZJxrKAzb8OJIO8fq8vvGb1N34gQjw3RxmmYybqdMgjpITXPRVYWlfhxwWjUCD/6mVDYaJjhPp1qetTjfCFexk582caEu7geF6jJUgVq0U5ERBkO3AHHzNzAUUw8rcI0KLEUpNcpRn8omNRaocnsHsUBCAG2+Cqeam5LDDjA7uNKLW/9bSiuV5NLr8Xl6c5KVV4RrId8cKG3qQwaPRXHB2XpK0eLLr8Bf3GLjvw1F/JcaR6HtvZzhoNsl6Oh67MBX+WX4bCqiXqyMeBGjjvSxLSFEpKxmpYKHzt8M4RoRUUCHfqVf2zEkWitdafrS53ln037DClUa5JBgZdMzN396Bdi6Y1fidqTxI36EOM1dUiq3O/QRLacxR97jkM5BVaZv/4OOzA/JptofSosvZwvjN1nTQekeZQd96i6AM88/X9exN3nY+LfZH6R8q1IYcIj6eloy7gM7ub5xrhwvJG42aPpSONT3j80wbQP7DzaKdZze/fukLA/WRUylC+ZYH/OAFa0zsagRi2oBZOYDeIsc6rk58DH3YtH3YChC6CdB9bz /crwrWTI riwXuIFNsRXZYJwuaBjVnw7rzH2Cfb25o5F8VhoZnx84X9wXTV6SyVOypF0LquJflLgJvrxRKhM9XjQ4RvrW/37ijAYHEyLM4kuJse1+aAOwpwghBkWdCiRUnZAVVl23usKTg8EzKXgV6pla4pn2yxA+/tA39nc4PeAntrVAsIA4CEW7Fu2OPdIr1DDG4xsqHrhKD2jwc/QA/JlwxnPa+rOHzbIOwNurANX1zkn26pGfkD1BMdRm86Z0sLmGpK8/uCb9ue5pL4sRRtbO9Ln73poi0UCOxP2g6CpiH 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: Update the test-purpose DAMON sysfs control Python module to support DAMOS stats. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/_damon_sysfs.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tools/testing/selftests/damon/_damon_sysfs.py b/tools/testing/selftests/damon/_damon_sysfs.py index b4f6e385c564..a75244451684 100644 --- a/tools/testing/selftests/damon/_damon_sysfs.py +++ b/tools/testing/selftests/damon/_damon_sysfs.py @@ -96,6 +96,20 @@ class DamosQuota: if err != None: return err +class DamosStats: + nr_tried = None + sz_tried = None + nr_applied = None + sz_applied = None + qt_exceeds = None + + def __init__(self, nr_tried, sz_tried, nr_applied, sz_applied, qt_exceeds): + self.nr_tried = nr_tried + self.sz_tried = sz_tried + self.nr_applied = nr_applied + self.sz_applied = sz_applied + self.qt_exceeds = qt_exceeds + class Damos: action = None access_pattern = None @@ -104,6 +118,7 @@ class Damos: idx = None context = None tried_bytes = None + stats = None def __init__(self, action='stat', access_pattern=DamosAccessPattern(), quota=DamosQuota()): @@ -322,6 +337,23 @@ class Kdamond: return err scheme.tried_bytes = int(content) + def update_schemes_stats(self): + err = write_file(os.path.join(self.sysfs_dir(), 'state'), + 'update_schemes_stats') + if err != None: + return err + for context in self.contexts: + for scheme in context.schemes: + stat_values = [] + for stat in ['nr_tried', 'sz_tried', 'nr_applied', + 'sz_applied', 'qt_exceeds']: + content, err = read_file( + os.path.join(scheme.sysfs_dir(), 'stats', stat)) + if err != None: + return err + stat_values.append(int(content)) + scheme.stats = DamosStats(*stat_values) + class Kdamonds: kdamonds = [] From patchwork Wed Feb 7 20:31:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13549052 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 65121C4828F for ; Wed, 7 Feb 2024 20:31:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D7E66B007D; Wed, 7 Feb 2024 15:31:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7385C6B007E; Wed, 7 Feb 2024 15:31:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D9E36B0080; Wed, 7 Feb 2024 15:31:46 -0500 (EST) 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 4C0F36B007D for ; Wed, 7 Feb 2024 15:31:46 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 20553A235B for ; Wed, 7 Feb 2024 20:31:46 +0000 (UTC) X-FDA: 81766153812.13.F1B47E6 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf13.hostedemail.com (Postfix) with ESMTP id 5AF1820015 for ; Wed, 7 Feb 2024 20:31:44 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Fi0iIujP; spf=pass (imf13.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=1707337904; a=rsa-sha256; cv=none; b=ahDIPF1+DAS1N37BE2L2rJPfzSPgQgvCIvSpb+4+ZHunwMqf8d3FmGJtK8CCEgRDw+cf3x FKKmnea2A9ZNqrXhfPhFcNTuxByFv7e4eORKxam0v2FH+byEo8SmoMex+qWmpxBiTd/+JN xEr76EbOgu8s3miGUv2J02CxX4/TAnA= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Fi0iIujP; spf=pass (imf13.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=1707337904; 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=lqk+XrNBIXzsY9QkTuWpsp4fsxkH9nn7jyu/kZayx0c=; b=nXcnII4pZRFWj6N5ZzKkV0g59M+7BnrRpF2Q4zp3No8iUnPzK8bezUXJss3iQE2uB9GrWY ZoB6827wsfTqUjjVZpyi/7VquPh8L2WQTVVsWwLwLNCcphyH4rbCIFJcpEpi2k9fWcwqp2 AKCaQCai9bJRGyTnOSPt5aaBJlZUtgA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 67DE861A9D; Wed, 7 Feb 2024 20:31:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8F1EC43141; Wed, 7 Feb 2024 20:31:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707337903; bh=9lLmi3bov7hQSKSz6Wm19r7FnAY+g94q4B/k/Jgsk9k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fi0iIujPz1cj5u9k8DV6O6k6jYHVEQy6PRbsmappiAAOUQnYijCrUO8m+mPpuZQ/X /Qo1XhekVUHY0pnANoHsgiT0y8eK/BMSLC0y9cvyLOUdXjSE4Z5pGSRSMoGYHhyAim 6ciDGu9LMatd++0cRpr5guC30UwMHR2ZkSRBnXrH+P2hqXseTOV9V0AYm4ptQ+1oR8 WyrAKtkKkKNbHEftXNZBqMKYhKIrCO073GUohgJLzwsRXP5cFQ37mbbhO3MOD+Hjea vWnP8dF05TL/cauWKBUB90aZFB1nilt2afMb5jOh3Dw+y0IppRqhHOpKyNog663RqN X4qIwvmvgRO/A== 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/_damon_sysfs: support DAMOS apply interval Date: Wed, 7 Feb 2024 12:31:29 -0800 Message-Id: <20240207203134.69976-4-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240207203134.69976-1-sj@kernel.org> References: <20240207203134.69976-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 5AF1820015 X-Stat-Signature: ykayhjpenfu8i1ogyc5orndo95i7itrj X-Rspam-User: X-HE-Tag: 1707337904-55177 X-HE-Meta: U2FsdGVkX19glFr919mH7W9+f3fhHYMDnaYb9kKio2xFD/ZHlPTGD6UdndGJicaLSEtxLvDqatMphTGFlL0ZbObUU8R386EEnxlNQJzZFdbB0XoQ4LPux5whye4CBQZkTCMeNUnzBD2+WISjMZ0DfUGCha00cBh2H66cq/uAHNF5o5ZdxMrKB1lgAKk1ojrAvXMBYw4CCDiJzybujDVrBmYTQCn34jqAaeb0ImKT/AeBXhp2s0ADw45U4U/e+MySpCunexKyaRZIRHuS9YcvL7N0+MCGKKfcmcsPK2fHy/OK6JhAiOCrg0G2xaV07P40vZBpjAkabm9h4tI7GwNjTcliljnXvOMXrIe0rI26qkSbyHSvTrwTwnZlaZc/NwgkENNfMHV2fo7UBdTHtzxh5olC8thQon4/erALYV9mNjPrt1NoRjN7R7cz0jRTRr9tjdLduwS3d2ukMAY4BfiCu56kGZSZ0cdqSz6G0lP60lsDw0AtmoQkPFGD9AUosEgPaszFp9m2+O1aAs9LADZQT8PlzbRUGEuDsic5hWh4f8/Kmg21RFOQFX1Om5RMI6tcKM4y5s55Gsc2a8dx3SO4JqffeHk7kQ4cDWPqoxLxSXYBWAE7klGmowGV/2DLZkRm71phxaw5Oj4fRHa+x8qLp0vBu/XEYcv6Em+RSmlUoYoaTWJOMvHOsXzBOsiRSA87xQVg23K5H9Z5Q9t9ZbX/En1EB8jm/7VGThRoQTCcwhqXUjyVccB/qXY4LTYcqmkXmzRYSfmdar3rBvKJJW22IuYPAxCfbal2xSLPdwjUMcJOYPQAmC5fZDQ2ekPmsdB7QZhHsNB/LqWzXxWmLgfTx65ai0mke8DDgNldkoF4U5R83Njy62VdjmmrbrhDDIebgu8EVVk2lAUjjOUKMnKVjvEB2nJhFziUbK/jEExqJvfpK8x4/4n1Cf3Nf9h9UESyArqVKkW27mCxx/wp4Ad 6cmWATwE GUJXBBsovTljX+PGZ+dEAI7Osi2+Nz7EqPCo0gWZXu1amsunOAzq4LzM7a5r9hKkNTNCFVR+jFpAgFtiSm9qebPIs3zKLgzx6FPdQ1S1Ct6YGEK/8hy/NbdQNHktGJDHYBtPE8X1eSyHgIv8EIapu4eqnlHWVI0KS5E9NTLOoLO+BH+Mp4hKXdP1TJhwYaCRZ5vGzy+KKL3Drg/P1AJV264+p5F1CF7pWj/kErkwnLP89WhBE0YHKlEVbRGBSlB6h8maEv9rM9CHLlcikbZ5T5nSuYKcmMP5sKQdT 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: Update the test-purpose DAMON sysfs control Python module to support DAMOS apply interval. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/_damon_sysfs.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/damon/_damon_sysfs.py b/tools/testing/selftests/damon/_damon_sysfs.py index a75244451684..d23d7398a27a 100644 --- a/tools/testing/selftests/damon/_damon_sysfs.py +++ b/tools/testing/selftests/damon/_damon_sysfs.py @@ -114,6 +114,7 @@ class Damos: action = None access_pattern = None quota = None + apply_interval_us = None # todo: Support watermarks, stats, tried_regions idx = None context = None @@ -121,12 +122,13 @@ class Damos: stats = None def __init__(self, action='stat', access_pattern=DamosAccessPattern(), - quota=DamosQuota()): + quota=DamosQuota(), apply_interval_us=0): self.action = action self.access_pattern = access_pattern self.access_pattern.scheme = self self.quota = quota self.quota.scheme = self + self.apply_interval_us = apply_interval_us def sysfs_dir(self): return os.path.join( @@ -139,6 +141,11 @@ class Damos: err = self.access_pattern.stage() if err != None: return err + err = write_file(os.path.join(self.sysfs_dir(), 'apply_interval_us'), + '%d' % self.apply_interval_us) + if err != None: + return err + err = self.quota.stage() if err != None: return err From patchwork Wed Feb 7 20:31:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13549056 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 C9A59C4828D for ; Wed, 7 Feb 2024 20:31:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 20D326B0089; Wed, 7 Feb 2024 15:31:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 16E916B0087; Wed, 7 Feb 2024 15:31:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB5716B0089; Wed, 7 Feb 2024 15:31:50 -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 C5B7C6B0085 for ; Wed, 7 Feb 2024 15:31:50 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 7548A1A091B for ; Wed, 7 Feb 2024 20:31:50 +0000 (UTC) X-FDA: 81766153980.02.D51F673 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf01.hostedemail.com (Postfix) with ESMTP id 16EC64001C for ; Wed, 7 Feb 2024 20:31:47 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DJJijCfm; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf01.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 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=1707337908; 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=HQsnQiHECGwZ+IIGXPseCKHddRHgG9/ugyekSKU9W1c=; b=VjMjZa1nPnsaPcX2Cph7WxFuOaQjGep6+KbDtbwHV+feH3Ek2o0Mc8bDi4P2R1dAkaRRB/ gJw8OVyAiCCT+Y4TluqzEUT0/cJniwD6Y4O8zeWNOfQZPaH7aeXv55RlnHZXINGEZsUPKe rIiYcGWWPHiUwwqKm+M7yk09XihBPuQ= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DJJijCfm; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf01.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707337908; a=rsa-sha256; cv=none; b=wU3OFFHhBwIzMXGsZaQNa/w8lzuSdJ+6FXKyLmspXcXenl0h/Dlov9hA3TEjHeH3C1b2F+ xgpf+/u3/gbifmsR2GCr8IhrFK3hZCmhvl/QhvObBTMDFXd/jDYcJaYu0dLx9/qKKqb4gB N1E7N9MbtOh6kaENqSAk34KC8UX24+E= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B8CC2CE1B03; Wed, 7 Feb 2024 20:31:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68A8FC43390; Wed, 7 Feb 2024 20:31:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707337904; bh=tz9uTb84Z42Yizp5Acw7rjIK4AMaxjqMzKQOqT/pm1M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DJJijCfmw4GrlAMLBl2nP9yduJUcln0mxAT/q50sI+tVVLy2pIDCclwCxcNfCEWOG 3uKNB+jqzsufuPDqf9L25wuWkXRB3clhwftLcRVBOtVOUEmEO9S8Q181dKzi37GUII aqtGfAyzwMiz0iE/qwfGcVHcQG99augNwfn8zblNS3xRUJtTnuyvWkcp3DDkMVQTLs 2F6ltet+/rUSxJuNO9aQjEUVy5vntT50wmjVCQ5ejj5fIqXFLj17s8lHTiCjCMpop+ bFWBaRWR7yfvnKot97njjwyosyXavwoeSgfyjAKNiOO1EH1z03lsyKV/Ew16tLZBML aePPCZfS9eubA== 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: add a test for DAMOS quota Date: Wed, 7 Feb 2024 12:31:30 -0800 Message-Id: <20240207203134.69976-5-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240207203134.69976-1-sj@kernel.org> References: <20240207203134.69976-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: fhgkoh479r55rqghas93919rt3yxaisr X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 16EC64001C X-HE-Tag: 1707337907-366060 X-HE-Meta: U2FsdGVkX18t8Fa5pP31bGXoS4Q06rHt8bIt9uvQLh+skEaxqKp2iVkt8s83PmVHVyZXz7eInWZ9fpuEbDOn+9LdAj3j9savY8gxkHG5dZQBdkjBdm3CfrKE58PfF0cTkbg1iQG1JF8+qFuj+V+AEFlLju8t/WOgDud755LH+ipJxqDlpjXBojEk8kfFWWgUSmqc6mefBtLpsq12j+ukyme0+X4guO2ceLMbfwtqDUiOYf+70tbY8sXM/eB8yP5PTquW17bhANfCFXTrto6fhombEGlGnEQlQHySCrKI9koGrJmTXkBLqW8q9r/7PLACONjHMTUjUBhSHGaZ0tKqIcjFP5jP4+wp9C6ATddIBUf0D5CBY+P4WhgaO+WaFZm9tlXQ+zAT2HOO2XZGejDNKIX3/luaplWEtKivVYWBxkESmQvCV4mjUUtqDbu1vhd9MFrmDkZVa9YA0BBLpRfdEEBX9fqPIWxs3JP+XktVox+X6j/utO6vBaTosqTN1yVeQQYVAlzqFS8BfGMyJP2jKDryiqGQB9s5Q0ToPMFvy4hRQ/2RfptYHu4o7kBHW+3md7BPrVKlhIOpr/bxYG8DNpvvEW9x3MvCWlmZui/N7uZgfh7K3KVP0h73qTdZcNWGIh2GTVJ6tklUIWBQ6YqvuSF8G/IeNY+HJqgYvbf4Y62LlQrZRlnopNHCRXBPll1AMDUkaXvX0duuB1xivB6Q4Ax/O6skloP3XKmJZ7NEasBNi6C1DBO/Ph5QbVmDsf6ZfV/i0lX9RVCkH69+o0CzYuQ4ApEoYyHWunAIOH5Jssk32NS4T48boHf5k37AAsPE6dt+Fee/uFtOR6atuozWn0n6fz7YQnVEpEf1aNimPgJa/O4u+fQiaW1Dp1+QTgTTp940DDTNVPnnWSJRBE9Wn9bm/t81+VSzURiKWGLrLLeA+Tqn9m6cy/2BwMQy09n1no4n+yJRjw1eix5k4Xl om/iilTA DxW+jJNLqe4aFzE2dD8Tz2BzFef16ecbe7MvUZcw8yitGJnjpLe90K6Dg5qgR46OeGc2Mr67e0tcVsV/VKgJxoEjDX7bb2bYgXZtGPQOYtVInrZd3tsx2GC4D5yTbME8FCe3E5z+HzZ42K7XwDWMjqmfEgkf1xN7U4Bv43bJ2bLHyOx3Sys8nTM4ppCK2bR9Cs0nIKKf8uQg/k1BDCirED0t1nMW4lEFpHhy8pKkwaHdQVFZTXbaOdDAjOiCB+fuDuz84 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, 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 selftest for verifying the DAMOS quota feature. The test is very similar to sysfs_update_schemes_tried_regions_wss_estimation.py. It starts an artificial workload of 20 MiB working set, run DAMON to find the working set size, but with 1 MiB/100 ms size quota. Then, it collect the DAMON-found working set size every 100 ms and check if the quota was always applied as expected. For the confirmation, the tests shows the stat-applied region size and the qt_exceeds stat. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/Makefile | 1 + tools/testing/selftests/damon/damos_quota.py | 67 ++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100755 tools/testing/selftests/damon/damos_quota.py diff --git a/tools/testing/selftests/damon/Makefile b/tools/testing/selftests/damon/Makefile index 8a1cc2bf1864..9c3783f1a39d 100644 --- a/tools/testing/selftests/damon/Makefile +++ b/tools/testing/selftests/damon/Makefile @@ -12,6 +12,7 @@ TEST_PROGS += debugfs_rm_non_contexts.sh TEST_PROGS += sysfs.sh sysfs_update_removed_scheme_dir.sh TEST_PROGS += sysfs_update_schemes_tried_regions_hang.py TEST_PROGS += sysfs_update_schemes_tried_regions_wss_estimation.py +TEST_PROGS += damos_quota.py TEST_PROGS += reclaim.sh lru_sort.sh include ../lib.mk diff --git a/tools/testing/selftests/damon/damos_quota.py b/tools/testing/selftests/damon/damos_quota.py new file mode 100755 index 000000000000..7d4c6bb2e3cd --- /dev/null +++ b/tools/testing/selftests/damon/damos_quota.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +import subprocess +import time + +import _damon_sysfs + +def main(): + # access two 10 MiB memory regions, 2 second per each + sz_region = 10 * 1024 * 1024 + proc = subprocess.Popen(['./access_memory', '2', '%d' % sz_region, '2000']) + + # Set quota up to 1 MiB per 100 ms + sz_quota = 1024 * 1024 # 1 MiB + quota_reset_interval = 100 # 100 ms + kdamonds = _damon_sysfs.Kdamonds([_damon_sysfs.Kdamond( + contexts=[_damon_sysfs.DamonCtx( + ops='vaddr', + targets=[_damon_sysfs.DamonTarget(pid=proc.pid)], + schemes=[_damon_sysfs.Damos( + access_pattern=_damon_sysfs.DamosAccessPattern( + # >= 25% access rate, >= 200ms age + nr_accesses=[5, 20], age=[2, 2**64 - 1]), + quota=_damon_sysfs.DamosQuota( + sz=sz_quota, reset_interval_ms=quota_reset_interval) + )] # schemes + )] # contexts + )]) # kdamonds + + err = kdamonds.start() + if err != None: + print('kdamond start failed: %s' % err) + exit(1) + + wss_collected = [] + nr_quota_exceeds = 0 + while proc.poll() == None: + time.sleep(0.1) + err = kdamonds.kdamonds[0].update_schemes_tried_bytes() + if err != None: + print('tried bytes update failed: %s' % err) + exit(1) + err = kdamonds.kdamonds[0].update_schemes_stats() + if err != None: + print('stats update failed: %s' % err) + exit(1) + + scheme = kdamonds.kdamonds[0].contexts[0].schemes[0] + wss_collected.append(scheme.tried_bytes) + nr_quota_exceeds = scheme.stats.qt_exceeds + + wss_collected.sort() + for wss in wss_collected: + if wss > sz_quota: + print('quota is not kept: %s > %s' % (wss, sz_quota)) + print('collected samples are as below') + print('\n'.join(['%d' % wss for wss in wss_collected])) + exit(1) + + if nr_quota_exceeds < len(wss_collected): + print('quota is not always exceeded: %d > %d' % + (len(wss_collected), nr_quota_exceeds)) + exit(1) + +if __name__ == '__main__': + main() From patchwork Wed Feb 7 20:31: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: 13549058 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 C08D7C4828D for ; Wed, 7 Feb 2024 20:32:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BFC6C6B0087; Wed, 7 Feb 2024 15:31:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BA79E6B0088; Wed, 7 Feb 2024 15:31:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9FD276B008A; Wed, 7 Feb 2024 15:31:51 -0500 (EST) 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 83CFB6B0087 for ; Wed, 7 Feb 2024 15:31:51 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5582D4056F for ; Wed, 7 Feb 2024 20:31:51 +0000 (UTC) X-FDA: 81766154022.21.62288F9 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf29.hostedemail.com (Postfix) with ESMTP id DB219120015 for ; Wed, 7 Feb 2024 20:31:48 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="JKgp/zT8"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf29.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 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=1707337909; 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=TxVl+5+Ve/BE1UaSuZaYB3tpzYwZOtnPjXlc6UL5oTQ=; b=UqcjccM2Yic4I8aZcDMl+swzD+soFqLrcHNniV3XLwxM2yjP5tp2pt0RXtMhuq8ybzfeVU LOTZR62yNVUupen9vny2ElcMKUgBfnd1lqsvfywjusXn+U1JhxWWURg+nGXlRU9k8WnRFN 2Uf2Lu9UfMmz1r18oDTS5cOgojXfR9s= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="JKgp/zT8"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf29.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707337909; a=rsa-sha256; cv=none; b=URemm6OuKcapsmOg0o1p40GV23YC65PZUnwAjgFKCcRvwiryDNl8ubg4zhjLE6R57JDDnX cMY3DgGp5D0CUXMlSOUKEvqb+d5fRefNlEtNHZR3RTeWT194EyHHaU0DuWh1qZzNXZMJHl hoG9E2nPNsSftYeKi7cPQZC7ytYvGHs= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 05F5BCE1B11; Wed, 7 Feb 2024 20:31:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 374E9C4166D; Wed, 7 Feb 2024 20:31:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707337904; bh=eTfAT8I3Zrsng6f7SuRxQKWrP7lIEivzKE3OpfIwwxI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JKgp/zT8soGxMNVpEjgN4T11q/PH3dSEMmOCuxrZk1KHb+x4aO+vHKx3WghdJTjjI U1vxJoRUqSA7K4mUYmEwBW/w7cVZ/AzEVXOVi2WJGSqr85PnQHEVDdbCphy53Hiobe ewQwBW7Pj5BnELlzpz1x6bHuaUUXU1pXc7qQN322bFOVRh4Xb0IFrPID3NY1DlUp7b SnTkVHx91YfY8ZxZosB/ENWyTggk4AGpTLXidmrJmcjX6q21CdrSENztmqzzCi4WBs AUnNKvucq+cG0+WD5BN7QIV7fUw/7zlR91K8CILvWsb1THqfz3lx4WtJWh7OFb7FSi 3SpnJ3QJj9rXQ== 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: add a test for DAMOS apply intervals Date: Wed, 7 Feb 2024 12:31:31 -0800 Message-Id: <20240207203134.69976-6-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240207203134.69976-1-sj@kernel.org> References: <20240207203134.69976-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: DB219120015 X-Stat-Signature: 611fd83fdwz4t1ntk9zt4g9z4w8mkn11 X-Rspam-User: X-HE-Tag: 1707337908-364247 X-HE-Meta: U2FsdGVkX1/Pg6NNrs0OpqwMF9XugXwVicEKqt3IxVded4VDDS0URAzqKUaFctqkVf4ttyM8NZoSthSi43piGlmoxCkD994WJGHjV1E4QrlvBFuJskYfAG/KXCmt2N9Qii/IQlQQuTwGad7/NyHbbam9z7UQqCT0OXDj1oBvSeHIzZVXyLLONBSDisHUy9aryTzI12y8FN73bo6edsrNehDoTzelBw1pkuQHzOYlPwgbrAT4sXQfPFzEoR/9Rp9IxWlE+o0jtwInGvvKUDijv3PTe86vlQ/8gBs4rXbr7tJnSUjSAezWsTUmeVdP5s5qJKpu3Fno1DDi75JoGc8qW5ppwKpouDJX85tlS1W3SnDX0X68ZbKhXEOAdTU+qFQAEkFgvCZn7lwJqiA+03O4CuJCDFrD4D94liwcMuuXybq/Yepf4L/LF216bCxaD7tvmMH/xO7/TvrThSldEDEoQ6Vuxxv68L/bQWtpqpEh8DD8HNVBcqX2vCXs0nI2iJ8y7ruOqc3/aJf+DTRZIvV24Ix9wkwGxPVhrUodSfeHXwOzsSWQoOSxhg//PFTwYdrZ3zqEAxksH+hyIAhh76i013ejOi421HgWL/EQOZBFNAFd73ap3bhvIlvckKLNGbL+AOtqJhBmwnS8r5faImGjKHalRpgOYWuudZhwjTQ4UFTn020+bYocVmwM7Z9o7PBn362BiYDSGbeMihTmAijZ0SmuMCvDWP3mc2XiHdr4DQ90U/zpIQThGhALtFq3Gk/aJRFaZkpiipx2eltTbiLYwwD4/OAsr2X9q8yMYjAQt+T0yRWNFumI+0qJ7TfqSwNeUSjR3ZzQkEMKUhSYyYHPxplbaSeuc4+zZFbg/t0AlWxsvh/83ogLhI/vNoiJ1xm0TYFXpYggROwMEhUdHwXNPqd2A4/HtsHXvxbzCqHpD2e7tDZ7+2XMyocMh8fq2wZ97P2A3VwV/POp4YoX33t xFfZD3D3 fPM3tnVBGTjrL8a9TwUO6PLvgONumEwga3uuBhvEFIiKrhxEcPxCWQB6yxe8mPTFMO4KGw8N+ZQElWcXQi/CcQDogniD/AKv1J7oLuk/kO6DLPWXMdHobeZ/GsuF6qAl5iXQce3+tjoPUBHW/BbNgHrl0VTnZRbRQHsamt4+k1Y8cu1hXDE/3ida/B2ctvMMTd7BRM4Znw16PogyLwPKCfLevYn4IKjD0QKV54EAlbu4UVsgdwvThspGdyyCxhAI8dxT8nQ9CHTux02E= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000121, 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 selftest for DAMOS apply intervals. It runs two schemes having different apply interval agains an artificial memory access workload, and check if the scheme with smaller apply interval was applied more frequently. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/Makefile | 2 +- .../selftests/damon/damos_apply_interval.py | 67 +++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100755 tools/testing/selftests/damon/damos_apply_interval.py diff --git a/tools/testing/selftests/damon/Makefile b/tools/testing/selftests/damon/Makefile index 9c3783f1a39d..b545fedafb3b 100644 --- a/tools/testing/selftests/damon/Makefile +++ b/tools/testing/selftests/damon/Makefile @@ -12,7 +12,7 @@ TEST_PROGS += debugfs_rm_non_contexts.sh TEST_PROGS += sysfs.sh sysfs_update_removed_scheme_dir.sh TEST_PROGS += sysfs_update_schemes_tried_regions_hang.py TEST_PROGS += sysfs_update_schemes_tried_regions_wss_estimation.py -TEST_PROGS += damos_quota.py +TEST_PROGS += damos_quota.py damos_apply_interval.py TEST_PROGS += reclaim.sh lru_sort.sh include ../lib.mk diff --git a/tools/testing/selftests/damon/damos_apply_interval.py b/tools/testing/selftests/damon/damos_apply_interval.py new file mode 100755 index 000000000000..f04d43702481 --- /dev/null +++ b/tools/testing/selftests/damon/damos_apply_interval.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +import subprocess +import time + +import _damon_sysfs + +def main(): + # access two 10 MiB memory regions, 2 second per each + sz_region = 10 * 1024 * 1024 + proc = subprocess.Popen(['./access_memory', '2', '%d' % sz_region, '2000']) + + # Set quota up to 1 MiB per 100 ms + kdamonds = _damon_sysfs.Kdamonds([_damon_sysfs.Kdamond( + contexts=[_damon_sysfs.DamonCtx( + ops='vaddr', + targets=[_damon_sysfs.DamonTarget(pid=proc.pid)], + schemes=[ + _damon_sysfs.Damos( + access_pattern=_damon_sysfs.DamosAccessPattern( + # >= 25% access rate, >= 200ms age + nr_accesses=[5, 20], age=[2, 2**64 - 1]), + # aggregation interval (100 ms) is used + apply_interval_us=0), + # use 10ms apply interval + _damon_sysfs.Damos( + access_pattern=_damon_sysfs.DamosAccessPattern( + # >= 25% access rate, >= 200ms age + nr_accesses=[5, 20], age=[2, 2**64 - 1]), + # explicitly set 10 ms apply interval + apply_interval_us=10 * 1000) + ] # schemes + )] # contexts + )]) # kdamonds + + err = kdamonds.start() + if err != None: + print('kdamond start failed: %s' % err) + exit(1) + + wss_collected = [] + nr_quota_exceeds = 0 + while proc.poll() == None: + time.sleep(0.1) + err = kdamonds.kdamonds[0].update_schemes_stats() + if err != None: + print('stats update failed: %s' % err) + exit(1) + schemes = kdamonds.kdamonds[0].contexts[0].schemes + nr_tried_stats = [s.stats.nr_tried for s in schemes] + if nr_tried_stats[0] == 0 or nr_tried_stats[1] == 0: + print('scheme(s) are not tried') + exit(1) + + # Because the second scheme was having the apply interval that is ten times + # lower than that of the first scheme, the second scheme should be tried + # about ten times more frequently than the first scheme. For possible + # timing errors, check if it was at least nine times more freuqnetly tried. + ratio = nr_tried_stats[1] / nr_tried_stats[0] + if ratio < 9: + print('%d / %d = %f (< 9)' % + (nr_tried_stats[1], nr_tried_stats[0], ratio)) + exit(1) + +if __name__ == '__main__': + main() From patchwork Wed Feb 7 20:31: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: 13549053 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 DA63DC4828F for ; Wed, 7 Feb 2024 20:31:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DCB9C6B0080; Wed, 7 Feb 2024 15:31:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D538D6B0081; Wed, 7 Feb 2024 15:31:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BCED36B0082; Wed, 7 Feb 2024 15:31:48 -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 A9F356B0080 for ; Wed, 7 Feb 2024 15:31:48 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6FE5312048D for ; Wed, 7 Feb 2024 20:31:48 +0000 (UTC) X-FDA: 81766153896.22.72B1C99 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id AEE47140037 for ; Wed, 7 Feb 2024 20:31:46 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Kb2oXTnE; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf09.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=1707337906; 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=rqjq/CwbHCXgPEB18xIZCSBiYr8N6Pvdhm3Ak795qwk=; b=2aJEK54S2SeMsNTBzGv+kT5zSZvNZHpRu5tIMS+WfJtiR2XqVpwSFQsLLHn2j1ZbNEZVr7 IasajqUiHEnnMSs4qDvsqw9kFlpJx410Ww7TP+thlvViYfWbaq5BrqFX+fXh+axPOpJc06 2XbFcaeQhVjs8rXf3tsHA7Bzho/5Lo8= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Kb2oXTnE; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf09.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=1707337906; a=rsa-sha256; cv=none; b=1JETHNlKhJxXs0F6b5SJJ6IFGxlivBbAJREAWuz/tRRMsUY9cmX9yHmgtIihqkOzxLbGa5 1gTQDKPlfPBKG7rCQ6qoqVMCGkqac+in2Va0hNPCBbwdX/hUVkAoAoaeWpmdkyoA02r2i1 UPoCKDdck1g6HDM2JZmkcbPqHCPlQkg= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D25D561AC9; Wed, 7 Feb 2024 20:31:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EDF18C433C7; Wed, 7 Feb 2024 20:31:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707337905; bh=S70M2GZNqYMqWcESwYxGcEzhW76DUgm+kbbaqJbCpdk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kb2oXTnE6R6F4wSlva8PlQVqRsigPUXebwXQrnwij+JJ0C0b0PBPFATsjYGBrIqnm 9Y2oe/yFwWE4brv0188AL9S1F+hjHdIUZm34lv7g1vdMpmwnxAMQhkPbKuQbS9GeEs ejyeJRqNduFrSwmajR92vuwy8PrCVze+OK1zr9vlBtzzAdpTxqOOa4VAiSUjTKq2YC 58Rkx9c6FpQ0lTpEpryr9vph4mf6eMRtpoOS5ZCfcJqfiLSG4GSBVZQwWw87gxDwuZ SOeM4Q42U078d5I4K5zVz+Y9XOZr/6+TQ8P2g3eOdcd9gStaXDIkw9JP1H5abEw1cb BjLSZNNWyOoXw== 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: add a test for a race between target_ids_read() and dbgfs_before_terminate() Date: Wed, 7 Feb 2024 12:31:32 -0800 Message-Id: <20240207203134.69976-7-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240207203134.69976-1-sj@kernel.org> References: <20240207203134.69976-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: AEE47140037 X-Stat-Signature: uiegkuqn7gnokhw6bf8x4ozzofpc6w9z X-Rspam-User: X-HE-Tag: 1707337906-556839 X-HE-Meta: U2FsdGVkX1/o3RGLAQB5wPpTb9xycqH/fG5x69zggSpmn5FeE8ZfILAbyQU60cJeMMG/2wNAFe3/Vr5/AI2dwQFEPBtYwFLl8BvsyeTd/QXW2VkBmBCwB7to9hN4km/yAGhLcGtEamFlDz9vQGjJk/yBWe+Ej/YEphal888pwJ15rtNeyM83DI1NzoLuQdsVhxhzq/sM6YRgvPnpCiMN1uxfPU4G4awWtgZ6w2eYpGxDnlEfa9YnXXsbz1t8D5Dc4YOTzLkkhO2GhajqyNoAUpeD0ACCmNsmzOJQB4U1DYZRqA4KY1ntTASXuYI1q6RyVHcAa933PGoF4wI3qi4VqfteiZ2bh53cON7ijkABFtJ3RODDzpvLqJJ6cC+wzyamMRGAW1ejmbdLF0jIJVCkqh0VFndIotGZkAaeQTiVLy/XupOrCHmwG8+2yJHbJQL0pqsT4OV/ZlsIKeZrBDn0d/QV+R/AdPvEL+XxZmncd7MFSWLEclNbpYgkkyvglt+cjPL5if85cQoeui9J+o3t1OVaSnlD/IHUQEuckhd/J1462m3wiVuNtX077E8mOQESs9A5Ucg2vcmicUI+C6khHH9NqEfbe/Vbxj9j/RahbjHhmPXoWOsaz2uQ85l4Z5pggpO1eVOwvdfzwIbBll4SzKk7nMfT+yKoYHJyuE90EI1KlfemkxXq9xyEN7fE8xlMCnHNf8eVd5PMbBd09ds6kYUgjjeFUvucNxW2TcWEY0ieugeKUf/cbCTviHGT9x6T0EGakU7IiLEYtVJ5TTD6xP28PFr4qMX05CHC6UHZa2LZVWpNc2K2M9R1aEkORtj3KKQLwZ/OT77eEp522231cc58O1m1+DBlnhVU0LFmUQ1hh9xmkh114cd9YqNIkXFYhLeM5+xRq8M1LIe5bzyrQLQBixY4t6qPVceyQJ//Mrm7mgaJuZA/B3spjZrN6gPjVTr1BoogI52Y9btEOcc OmkXG9C5 zzGiOd6O1vE60+7NyRtc/8NLGDbNEClHEOJCvCogg4zUSINeSyisrWmG9EojT0J8yhhu3yscfR6oxMKfJMna8ASgcWH/SRRBVlax8vlGNDDV4xs7qUyBSuAC/KU2u7tiL8FybhqbobkX2gA3kPZR/GsTKLBA8ejRrYLs78nlWweqLmVTP6Ip15EbaG1Q80zRi37HMO8CPlNYwxUdWNJXfhpaSkQODQSJ1J5tVaDk6cjk+0UpcGU/+OWl7Z8pWdJtRqx5cIrIu9uoUNhFuEeD3sH/n9sgwYncNaViD 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: commit 34796417964b ("mm/damon/dbgfs: protect targets destructions with kdamond_lock") fixed a race of DAMON debugfs interface. Specifically, the race was happening between target_ids_read() and dbgfs_before_terminate(). Add a test for the issue to prevent the problem from accidentally recurring. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/.gitignore | 1 + tools/testing/selftests/damon/Makefile | 2 + ...fs_target_ids_read_before_terminate_race.c | 80 +++++++++++++++++++ ...s_target_ids_read_before_terminate_race.sh | 14 ++++ 4 files changed, 97 insertions(+) create mode 100644 tools/testing/selftests/damon/debugfs_target_ids_read_before_terminate_race.c create mode 100755 tools/testing/selftests/damon/debugfs_target_ids_read_before_terminate_race.sh diff --git a/tools/testing/selftests/damon/.gitignore b/tools/testing/selftests/damon/.gitignore index c6c2965a6607..7d6c6e062be7 100644 --- a/tools/testing/selftests/damon/.gitignore +++ b/tools/testing/selftests/damon/.gitignore @@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only huge_count_read_write +debugfs_target_ids_read_before_terminate_race diff --git a/tools/testing/selftests/damon/Makefile b/tools/testing/selftests/damon/Makefile index b545fedafb3b..8a3a8df003db 100644 --- a/tools/testing/selftests/damon/Makefile +++ b/tools/testing/selftests/damon/Makefile @@ -2,6 +2,7 @@ # Makefile for damon selftests TEST_GEN_FILES += huge_count_read_write +TEST_GEN_FILES += debugfs_target_ids_read_before_terminate_race TEST_GEN_FILES += access_memory TEST_FILES = _chk_dependency.sh _debugfs_common.sh @@ -9,6 +10,7 @@ TEST_PROGS = debugfs_attrs.sh debugfs_schemes.sh debugfs_target_ids.sh 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 += debugfs_target_ids_read_before_terminate_race.sh TEST_PROGS += sysfs.sh sysfs_update_removed_scheme_dir.sh TEST_PROGS += sysfs_update_schemes_tried_regions_hang.py TEST_PROGS += sysfs_update_schemes_tried_regions_wss_estimation.py diff --git a/tools/testing/selftests/damon/debugfs_target_ids_read_before_terminate_race.c b/tools/testing/selftests/damon/debugfs_target_ids_read_before_terminate_race.c new file mode 100644 index 000000000000..b06f52a8ce2d --- /dev/null +++ b/tools/testing/selftests/damon/debugfs_target_ids_read_before_terminate_race.c @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Author: SeongJae Park + */ +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DBGFS_MONITOR_ON "/sys/kernel/debug/damon/monitor_on_DEPRECATED" +#define DBGFS_TARGET_IDS "/sys/kernel/debug/damon/target_ids" + +static void turn_damon_on_exit(void) +{ + int target_ids_fd = open(DBGFS_TARGET_IDS, O_RDWR); + int monitor_on_fd = open(DBGFS_MONITOR_ON, O_RDWR); + char pid_str[128]; + + snprintf(pid_str, sizeof(pid_str), "%d", getpid()); + write(target_ids_fd, pid_str, sizeof(pid_str)); + write(monitor_on_fd, "on\n", 3); + close(target_ids_fd); + close(monitor_on_fd); + usleep(1000); + exit(0); +} + +static void try_race(void) +{ + int target_ids_fd = open(DBGFS_TARGET_IDS, O_RDWR); + int pid = fork(); + int buf[256]; + + if (pid < 0) { + fprintf(stderr, "fork() failed\n"); + exit(1); + } + if (pid == 0) + turn_damon_on_exit(); + while (true) { + int status; + + read(target_ids_fd, buf, sizeof(buf)); + if (waitpid(-1, &status, WNOHANG) == pid) + break; + } + close(target_ids_fd); +} + +static inline uint64_t ts_to_ms(struct timespec *ts) +{ + return (uint64_t)ts->tv_sec * 1000 + (uint64_t)ts->tv_nsec / 1000000; +} + +int main(int argc, char *argv[]) +{ + struct timespec start_time, now; + int runtime_ms; + + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + exit(1); + } + runtime_ms = atoi(argv[1]); + clock_gettime(CLOCK_MONOTONIC, &start_time); + while (true) { + try_race(); + clock_gettime(CLOCK_MONOTONIC, &now); + if (ts_to_ms(&now) - ts_to_ms(&start_time) > runtime_ms) + break; + } + return 0; +} diff --git a/tools/testing/selftests/damon/debugfs_target_ids_read_before_terminate_race.sh b/tools/testing/selftests/damon/debugfs_target_ids_read_before_terminate_race.sh new file mode 100755 index 000000000000..fc793c4c9aea --- /dev/null +++ b/tools/testing/selftests/damon/debugfs_target_ids_read_before_terminate_race.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +dmesg -C + +./debugfs_target_ids_read_before_terminate_race 5000 + +if dmesg | grep -q dbgfs_target_ids_read +then + dmesg + exit 1 +else + exit 0 +fi From patchwork Wed Feb 7 20:31: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: 13549054 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 CC45BC4828D for ; Wed, 7 Feb 2024 20:31:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D82D6B0081; Wed, 7 Feb 2024 15:31:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 760F86B0082; Wed, 7 Feb 2024 15:31:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5DBB96B0083; Wed, 7 Feb 2024 15:31:49 -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 4ABC86B0081 for ; Wed, 7 Feb 2024 15:31:49 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 21EF64056F for ; Wed, 7 Feb 2024 20:31:49 +0000 (UTC) X-FDA: 81766153938.14.D22F4A6 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf20.hostedemail.com (Postfix) with ESMTP id 612501C000C for ; Wed, 7 Feb 2024 20:31:47 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ou2UWhF7; 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=1707337907; 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=pEYzds38qzJkO3LwswAGZ3BaHAxTO2WCf8jM4flPQbg=; b=Jo/mle7nMdmsLWOwFe94feQrKG9iQLaWumqxuyiPCbS/h8reCqicWsGk7FhE7BkApkRzsb whE9M3g7tYSOiaRr+le5ZQm1vallP/ss5W6KL2wUTNwJuTPRZqeDidyX3eWwbtXH+OQwPJ CRikLV2j37WiS723iUyKv+KBVJRQPQM= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ou2UWhF7; 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=1707337907; a=rsa-sha256; cv=none; b=WtdAQ5FNIK0gOVJ2SYDAXBlPovNxQsgnCOZAGGEhOYgA8NqBgdzYgjKxDqpE0PflCgMPlK RAJK30ceYx07gsI9Lfn+C0+kKpv8SdYkDk/uvJ7zy6tmrAuOULhr8agqPvxPrZK7/XRaQf tsTcTrHFB9zyI/CIS14LBm0UdLC5YmI= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 7760561AB2; Wed, 7 Feb 2024 20:31:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7C72C43601; Wed, 7 Feb 2024 20:31:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707337906; bh=hilY7j3dbTrTcHQNZ5cH9hllN5vVoaZDnsr9bRpaZZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ou2UWhF7rKY/SOJPhENMHQfU07MoTtvz7MvwRRiYyi+LjIzxD5rbLHTVaXLNHZNR9 lFR6S9udTLIzBtTPoxRQGoEdVNalxZkr/elBolMd/SfH5QFGWjwos7+/sf2oAiOq3O a6wJNdJoaYJLL6Pv7h+oUyC+TN00MUk5ipl7S00Kd4NrisZHeGUSddyvn2IdWwCrMQ hdF+ZGVnRCq6QPicoYIQAGTLPPsGo5wDuRIkS4FTPC6TdAnAI6C8OEOEiHLUXNw9HY rZHgPKwBjJ/k5VGnsnvlP2zcb9HXC8V/mPlVuA6CTPFbN9CplEBU2O9p3H+PGt2+3J 356gekiMFzpVg== 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] selftests/damon: add a test for the pid leak of dbgfs_target_ids_write() Date: Wed, 7 Feb 2024 12:31:33 -0800 Message-Id: <20240207203134.69976-8-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240207203134.69976-1-sj@kernel.org> References: <20240207203134.69976-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 612501C000C X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: zu3hzdjrj3zes7z3ogxsr9sdctb4drxe X-HE-Tag: 1707337907-628590 X-HE-Meta: U2FsdGVkX1+U+utK5EhtbrYlzngQ11FHCPxChpLbFayXXYK51U6TQESqc/1pUAWNjwzwmf3uhgeCViGqclvyZmjj+abRmXtEKXg8FjIbc8OI/s+XOE+CTnWfePc74zqIv68QG1BRi2++scUKjL68d+6pJ4cqsAVyqLyXbOnJlEHaxvV78ko9mTrgCYsyPnkfszRhKyYbhyi3+KHj7X4JVH6JrsT4kkrbEdMxMAbzFy5tD9a5pVKSzkRd3TCRTUI4aoVh6fQeJCBbc3VKuqoV481OBGzDVJOtNzFEA9JXw13Isxy1cs/thDv4FqZRrIDaJgylqxPG/k8uY2lmOsVvJc0P9vRr4GV1s+WWqfl3lkw+pTu9IU6cvTrn/V17nq1R1CJUQLZpMKmQ/f1J7f1aP/Z4gq5XPDwXMr3V4B+yJcAMXZxtZ9K76pj1fJyYJxZe3chRsHKUyDGjTLea2j9yhAyZuzCAGQ3HBwR/EX/zP7zAT8is9OeYPfSRGA6bAPAzoIxj/4xHlD0Qv79ihD2BuIfSZ6OAmOSLvmcMSeLLxkbPasAD217mzYtKsDpqQVBNhzbDFbeKGvj9+trMhAygD8R8OCx5aPT8x/U0NVT66DG2OJzv26R4ehWMj/A34OdhcqZ8XeSpscB7nrFG2kD/AI9haBh9YpzcskRSJ9++0u7vbtgf7C0vzcaNh4G890IcrdjBxgnfxXwV5mEPtzOObQ8HzlfzXPSbB3jNAJBglvlYx68/lvkS9cMmD2l/kgJA+TzpDxhAtGKq7D67INslnszo8oqUAclLoWbj/W6lSYU3ulFjYfwjV+sP27x3BJSFg3/4+y5cuK9gF7o1eJeHgO+9J1IFBh/1/I4xnjHYqeVZRc/lraOuAxKWne/Om3xCEcz25uMqrMN1aGDqsz400dMXPNSX4OX++J+of1iDv08Vsbk8cEznlYjyZf05akzjnUPgRBIvz8Hm+7VEb1C 9XNxaa8F Q9emp7G7A0pR5c74fIHteO5zuhebYn4hcw84zXIEtbq/yUhPctAyb2ZrKJtNymtUvGstTEPz+xXJjfQZrBASxd9qWVZLvWXAVyNL4rHHbYwOqj2NOojaeR55/KphQSI0ZnHNP//9ho2F8Lnl8r+5z/HWp1Xg6ShkT+FOMbrOiJlzCk2kYROk7tX1dbBFZp5ngp3d+LaR0rePpX46IIr0Qim5hO+0HoFQfspCEKsg+zFeWlwLYKTWvL0KZSYqkp/OcNvY5R6BkzhkFeuBEGzHnphcFkjgArBgN7wX4PVV4W9H1JYaUNF+47BBvznH9Yaf9Amt7cMmCGv7Ks2wbqfvJDMd91g== 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: Commit ebb3f994dd92 ("mm/damon/dbgfs: fix 'struct pid' leaks in 'dbgfs_target_ids_write()'") fixes a pid leak bug in DAMON debugfs interface, namely dbgfs_target_ids_write() function. Add a selftest for the issue to prevent the problem from mistakenly recurring. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/.gitignore | 1 + tools/testing/selftests/damon/Makefile | 2 + .../damon/debugfs_target_ids_pid_leak.c | 68 +++++++++++++++++++ .../damon/debugfs_target_ids_pid_leak.sh | 22 ++++++ 4 files changed, 93 insertions(+) create mode 100644 tools/testing/selftests/damon/debugfs_target_ids_pid_leak.c create mode 100755 tools/testing/selftests/damon/debugfs_target_ids_pid_leak.sh diff --git a/tools/testing/selftests/damon/.gitignore b/tools/testing/selftests/damon/.gitignore index 7d6c6e062be7..d861701f0327 100644 --- a/tools/testing/selftests/damon/.gitignore +++ b/tools/testing/selftests/damon/.gitignore @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only huge_count_read_write debugfs_target_ids_read_before_terminate_race +debugfs_target_ids_pid_leak diff --git a/tools/testing/selftests/damon/Makefile b/tools/testing/selftests/damon/Makefile index 8a3a8df003db..789d6949c247 100644 --- a/tools/testing/selftests/damon/Makefile +++ b/tools/testing/selftests/damon/Makefile @@ -3,6 +3,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_FILES = _chk_dependency.sh _debugfs_common.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 += debugfs_target_ids_read_before_terminate_race.sh +TEST_PROGS += debugfs_target_ids_pid_leak.sh TEST_PROGS += sysfs.sh sysfs_update_removed_scheme_dir.sh TEST_PROGS += sysfs_update_schemes_tried_regions_hang.py TEST_PROGS += sysfs_update_schemes_tried_regions_wss_estimation.py diff --git a/tools/testing/selftests/damon/debugfs_target_ids_pid_leak.c b/tools/testing/selftests/damon/debugfs_target_ids_pid_leak.c new file mode 100644 index 000000000000..0cc2eef7d142 --- /dev/null +++ b/tools/testing/selftests/damon/debugfs_target_ids_pid_leak.c @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Author: SeongJae Park + */ + +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DBGFS_TARGET_IDS "/sys/kernel/debug/damon/target_ids" + +static void write_targetid_exit(void) +{ + int target_ids_fd = open(DBGFS_TARGET_IDS, O_RDWR); + char pid_str[128]; + + snprintf(pid_str, sizeof(pid_str), "%d", getpid()); + write(target_ids_fd, pid_str, sizeof(pid_str)); + close(target_ids_fd); + exit(0); +} + +unsigned long msec_timestamp(void) +{ + struct timeval tv; + + gettimeofday(&tv, NULL); + return tv.tv_sec * 1000UL + tv.tv_usec / 1000; +} + +int main(int argc, char *argv[]) +{ + unsigned long start_ms; + int time_to_run, nr_forks = 0; + + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + exit(1); + } + time_to_run = atoi(argv[1]); + + start_ms = msec_timestamp(); + while (true) { + int pid = fork(); + + if (pid < 0) { + fprintf(stderr, "fork() failed\n"); + exit(1); + } + if (pid == 0) + write_targetid_exit(); + wait(NULL); + nr_forks++; + + if (msec_timestamp() - start_ms > time_to_run) + break; + } + printf("%d\n", nr_forks); + return 0; +} diff --git a/tools/testing/selftests/damon/debugfs_target_ids_pid_leak.sh b/tools/testing/selftests/damon/debugfs_target_ids_pid_leak.sh new file mode 100755 index 000000000000..31fe33c2b032 --- /dev/null +++ b/tools/testing/selftests/damon/debugfs_target_ids_pid_leak.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +before=$(grep "^pid " /proc/slabinfo | awk '{print $2}') + +nr_leaks=$(./debugfs_target_ids_pid_leak 1000) +expected_after_max=$((before + nr_leaks / 2)) + +after=$(grep "^pid " /proc/slabinfo | awk '{print $2}') + +echo > /sys/kernel/debug/damon/target_ids + +echo "tried $nr_leaks pid leak" +echo "number of active pid slabs: $before -> $after" +echo "(up to $expected_after_max expected)" +if [ $after -gt $expected_after_max ] +then + echo "maybe pids are leaking" + exit 1 +else + exit 0 +fi From patchwork Wed Feb 7 20:31: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: 13549055 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 00C93C4828D for ; Wed, 7 Feb 2024 20:31:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1E4CB6B0082; Wed, 7 Feb 2024 15:31:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 195456B0085; Wed, 7 Feb 2024 15:31:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F28736B0087; Wed, 7 Feb 2024 15:31:49 -0500 (EST) 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 D1B2D6B0082 for ; Wed, 7 Feb 2024 15:31:49 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A9D70C05B2 for ; Wed, 7 Feb 2024 20:31:49 +0000 (UTC) X-FDA: 81766153938.12.29DDD2F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf24.hostedemail.com (Postfix) with ESMTP id 06A2218001B for ; Wed, 7 Feb 2024 20:31:47 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bZjKuePx; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf24.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=1707337908; 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=fX7x7KF5C9VADl9D4i1WzsxN5l8ADYMGFpSB6bu2YWE=; b=0DFD2NDOYAPcrCaMB/ApzAabNdZN9GvhZtA8ySkMxUByaRZ7wDZoLC/QEfXQLDvdFmWTP6 SJr/F2k+G0TPZWWEcO9iFjMmGwmOpDuRU10SKEG9pyoBByU2OJTGfJDxVWrKd79Zq/NgkX qJhyAMIED4B0RD2QbRaezQzYtwAfRYs= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bZjKuePx; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf24.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=1707337908; a=rsa-sha256; cv=none; b=f3YGpoLb9o+NL+KJIxhvK4FByH0PiDW8R5wlfKaUj/JA+S1+qb+c/s3qWo1U4WSKqAAIDM A2V0L/A29sfeK3DO/8nVi3/QN8Uae0sEW0hC9bvsi9woUsv4WFtkHtQV+U0rGfdD3u3zbw KmJzvCOzkQo56bu0brERBVo6gemqRKs= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 34E9061A90; Wed, 7 Feb 2024 20:31:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BA0CC43142; Wed, 7 Feb 2024 20:31:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707337907; bh=bo48Sw4QueorxjSh+Ck9B6Mrnc7pi7WnA/Re94O6ZTo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bZjKuePxNwzjVi/Qv2DXVeStIOUrZJHJYuqVTzb+TgaleSHCdDc57bdrDp2DxAX3q tRduOaVNfL1p6H56MRwykS5lAAwln08xpqJTJn8U1LGaVj6v8Db2XM9nwyrpve4Yu8 zMqsG+ifH1Z5Zo9j7NpyGkqJBhe1nZv2ZrGOSUQxJrqtNZYdBHNOIoDC4yEUOrdBDU TWkYBjx1+scE9tW43zJLFEApIyP2qJQRoBwtAzZMKV3eaqJHrkrFio8N8hlKJTpB4Y 2PAJKPUeIiNECiNtD0y1VJ5z3hBfdLm+eqHH24vbuI+smXyAFJaXUuwPzkLoORW1rb vBYeGFwVYMdZg== 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/_chk_dependency: get debugfs mount point from /proc/mounts Date: Wed, 7 Feb 2024 12:31:34 -0800 Message-Id: <20240207203134.69976-9-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240207203134.69976-1-sj@kernel.org> References: <20240207203134.69976-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 06A2218001B X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: yzkesmkqpuisawd4onx7rqxj93g3sq1p X-HE-Tag: 1707337907-914534 X-HE-Meta: U2FsdGVkX19cGptjUXF/JxbkoD5rNDv3e76Oxlq9j3396O3fTeOQHgy8xfWWh4WLIBrtQMPvjbdcOQ+qzPbkF9XwwzN76DjycNNVynvrxZjYoxGpQw47LPd5h7U+SGqCX+7San17lg5HcUmJn9sIcU5J8wNg2W0bcNCRr2VpVIHSiPd6KTpeJ3rLyf0UvMdFPiQT73wisw5V5xU54hG8esXFewfN3qCSDLQg97fUJTPfTqsucQvNdeaMiRhvet9AuCw84+lDZO45ZXLBBNwDHDVyc7iZJIAUrT3VnAQ7eJfqimyC0NAHjgmjWCM/sjsBRF98+5/mvcyXYIOC/zj2nRUjDFaKmhL2WsqoiOF5gM7m9jt6ohmIopMLX8VMEijCiCJG2fZGR05dtLpmn6mrf7o8e45QAIAdohbndvf++D+VwtNd62xsZZKbItqcGLZAkULqEEzBg8idKx0EQvPp5xkIJWbpWmH/yZmEL6N3pebpqkJ6Zry1Hi/l7gP7nu+qRxaiZU+v0GfVx/nJ36Rec3XqwhiF2HLFreJ1RGgJJGSudKA/3YtDoNECTC3rtAzieCk9B8eydIaAt3ldsoSTH9LPZUDGPPuWobrez26fP2NErgUtLCxoUm7DwDAegfkK/7GgIxHmiIEp5jr+Bf4O5YmKr6ASJSxc75n5jCU7yCG8MsmZA9Mi2MWkYJe5rEaLJvBBAEYt9P3owoUlAwkQ4bUjVmVPVWclJfSh1tPkLceiDKRSTow6tLgw2ojHlf5zFgOHXgXOB7OAWIFdLJeYOn2N2LVD8g1n7I5SpSdh1732uPE6wSHSPQIj061Ng3i8XN1u6U0HFjD1SQcdGol+BwbuBLqNAnomDQxFtMerbdnNoFQreQ1hdDBgOmDQJq4+S674cfoL9Jf/99QIUMvCoY0+YBkUxTR4K20KRrj+T0sFWIfPoxrRKIHlt9K1UDaZyw1XGkkbD7BNDpO7N7m k3fMj89s K9+EMY61MbZWY4b9cf+rZWNR2I+zWy+T/A8wT9A8TgF6OpuUArHa6iqXWqQKfdj/Z54w1eIm7g/UfVxfEUUrrr8F/8r7k3Mu5c0bQu8Jbjbzb2tbMtBVSySdh4dCiiYMNu+CgwLy4HZoMDfuDWPX4XBW89TYwjiGW3DLvnIvflZBNdwX7mFKuxw6gc2p6rkl5YHs+pqFri4656qVf1er4LEZeLf7ZwDD6+oXalxbxpZqDF9UuK7G01X3R5fVpvrg+hGk3YL3W52V9uIa+rNufb7kh3yD++JNWzRqL 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 debugfs selftests dependency checker assumes debugfs would be mounted at /sys/kernel/debug. That would be ok for many cases, but some systems might mounted the file system on some different places. Parse the real mount point using /proc/mounts file. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/_chk_dependency.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/damon/_chk_dependency.sh b/tools/testing/selftests/damon/_chk_dependency.sh index 350f8c2b071d..dda3a87dc00a 100644 --- a/tools/testing/selftests/damon/_chk_dependency.sh +++ b/tools/testing/selftests/damon/_chk_dependency.sh @@ -4,7 +4,14 @@ # Kselftest framework requirement - SKIP code is 4. ksft_skip=4 -DBGFS=/sys/kernel/debug/damon +DBGFS=$(grep debugfs /proc/mounts --max-count 1 | awk '{print $2}') +if [ "$DBGFS" = "" ] +then + echo "debugfs not mounted" + exit $ksft_skip +fi + +DBGFS+="/damon" if [ $EUID -ne 0 ]; then