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: 198080 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2488893dyb; Wed, 7 Feb 2024 12:32:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IGYhm0ocv/33RtudsqPvdC1lOC4bXlu4EUWW9plm3/TKRtdap/zSzdZghucSUHT0dc4cPuO X-Received: by 2002:a05:6a21:3283:b0:19e:aa94:4efa with SMTP id yt3-20020a056a21328300b0019eaa944efamr1619002pzb.6.1707337958040; Wed, 07 Feb 2024 12:32:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707337958; cv=pass; d=google.com; s=arc-20160816; b=fpCbP7FrpIdG6+DEaDEZR0F/mEt8wNpF7OYNCJ7/mZXajYdZg81EeguBzSW2KxIoX/ C51NWb2WnbBpPphsNcVyDcbaa4ITtXMLUdLu2PNp+jznroVHR1bXJ5MK431wmYGOHvEW u66DAN6wjRKdldva6QqXV/7IDnU3zIoa0PlbGb+mNPQzf4VBXrf9ePxAeG7ciUf5atSa DbQTpAaMTtyhiVwrkzUIOj2JFfirqvL0mrGaSCrAs1W9pyohv4kdhXtwjiw6c2B/Lu4z 3IVr0HB2B/VRmnPEHJROz8U+sw/rPgWhCC8A9LicbUBMBjhjWav8HC3nnRbxcqn7MkQe OJQQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=e1UvP10+60uT60vfwuQyHfpn7s5IoP2FL/alemxKsK4=; fh=v8BcCmwdY55W69Ucud/ayR+1GdOPbKeJ44g9oq6P/GM=; b=neXEHHtUmfiFTy/oEXqLVeUY5lx99IKdj6Q5at8P1XILij7LA6Xa+SmlomKEtl49wG XSp/FzxaAw8zq1eJOyCKGZ4hRTfLvEzEWPb9M2oIM+lxQb8OfVr4FEzDlJAuypaByG4x +AjqwBU2++iG6frnRfnKk59bfqHhhEwsf3yLEMAcibnAN/bCbNrNWmR9jEgTS6Ay0ME9 KTrsA3j+hW3VcugojXE7jukfm+ODkZ5xnxZy0nhA5w795ce/+l2q5as6rJDW5A4ZpUik ofLpAAA/pXUx2qjVvkc1xPr3T7PF5ID4zCGkRVGIndvudBRfVaizuURZMQk6GbZzH5Yz Tj9w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lx8mnNCB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57027-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57027-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCX+AjBOScrwWD2XjLzGNKaH1/RP+vZ105f2M7yyWyqpWI9SPRvMhD8dsPjDFnXmGIQF95McpTmbb3i8t+wstbOKXGTIRg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id w5-20020a17090aad4500b002906b739813si2322840pjv.151.2024.02.07.12.32.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 12:32:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57027-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lx8mnNCB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57027-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57027-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7A06428E614 for ; Wed, 7 Feb 2024 20:32:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AF1B21292E2; Wed, 7 Feb 2024 20:31:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lx8mnNCB" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB3B01DFCF; Wed, 7 Feb 2024 20:31:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707337902; cv=none; b=Y5ptnmAGeCePnxTmXtRU8u8RyVkGEjksqNZlfqFICbHsfKxU9ik/PTMZZzRxzhDZ4POb3wsQ4F+Iq8BBWDklO6DbGvQMuGujjgr6yUnHq74vhYW67VoGZiqE87Ie7PubU6rNnP37Nchog1uYkVQYsnKDfWlPAGCzfrMcod/67M0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707337902; c=relaxed/simple; bh=JQERS+AD7eJcXPmEIi+Gcjav4/4TJSgTRdHhSGiTeC0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=a48RB+kQZnQ9//V/P3YOPiUZX8bp9UlB4FP2BgHyWRkecDdXk6kDaSBt1Kh0RnHjH8Bw6j9KtvUN7iDDbFxTgfZu+XEpMn+wqu6KeWa9BdmJ/pP1+QcGuT7e33Bp49W8bCf8zCJsOvDQZvku7OfJO2tC655xKmqXh/I8zegAipo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lx8mnNCB; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790273606721844540 X-GMAIL-MSGID: 1790273606721844540 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: 198081 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2488920dyb; Wed, 7 Feb 2024 12:32:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IFfdIrOOeXoABUwp5u6N2RUx/GTT7rnFGi7iQ7cPnrRTwIyh34m1gldkISggICroiEk5R3S X-Received: by 2002:a05:6808:209c:b0:3bf:ef8c:7be6 with SMTP id s28-20020a056808209c00b003bfef8c7be6mr2007770oiw.5.1707337960633; Wed, 07 Feb 2024 12:32:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707337960; cv=pass; d=google.com; s=arc-20160816; b=AKDh8Jkc4DOhGRK4FA3xvyhXvv0HfeCrn+BPIICyixbsJYkfEDsDjmZ5uKhWrlOwlt v/BOLX6+SVVyHW6H7anzXURCETSvBLS67DTgqRX88TgYQ8Nkf1H/PrfKqTeV7Sy2LPk8 O/0FMtEfyg1uVHDxV3Jr9uyHY/8ge8JdHghMDd4b2WOYiCIyzQDgP9CvxFjLJkYzq8Yl yX/juFaMHoijWa1Ab7/8J+LIiUd5M1QITUZLjNA84xDk8ws3gCdmCC87mu/ZarVfRF01 zwXP4tVLUbl2tiC4famUBUw+JnRhex6N0RhXEKS8BpiXeb0Xk04eF3BHXqKyoVBu17N4 DtRg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=z0T7CeVYOD9GKKEfBy3IV150lcFUebiMsZa/LbzzEfc=; fh=BTSAfExrJ2F/r6IzqRzEDxoHU6gL0Axn8CHyjnxqnIs=; b=H1hIajwT8scvMFNfbdtNOiiFCcYGddL9K7oqSVFFoh7d6p4FC2ywlQ2SBrDs05SX+Y HnGtsOiEGooXIk0N/A785HDlIYEbZzCCvBgGlorKdOvcMRXXVtbQaJTceFxIfmSwz8hj Yon05H4ojE5azEOTgjjogLmCMtBONK3jhs/3xm+/ejzGvEkTZTmSJcvK0mqzWk3VELEz ElyagACpBap2GUnyHIUEMeyHgNI6h+DGB6AH4/KLeBtEhEDuSlcKerXGtZ0moFklOpbP 1aekuNbyD1ZKRXrDbaOyaSmFP2TB2FcNfQSEh5KDe7JWmHH/ExY8jQcMMYkr2cejUDxR vkRg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XdziAUn9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57028-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57028-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCUjDj+fZbiij+QcuOAmcQoCt5JQngRnxliN8/qgzhlmM4F2os96y9MdBKseg0cyqwmzmhc1bnQnmoGCdNXlDWXJnkupMw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y6-20020a05622a120600b0042c270027afsi1959094qtx.66.2024.02.07.12.32.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 12:32:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57028-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XdziAUn9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57028-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57028-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 655201C24C06 for ; Wed, 7 Feb 2024 20:32:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C27A81E51D; Wed, 7 Feb 2024 20:31:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XdziAUn9" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A31B76039; Wed, 7 Feb 2024 20:31:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707337903; cv=none; b=dvfrwedygiv5+6KCTzhCxKmQ8xA0VYgLya953AQehl0DfIAc9AVzDArJLCVva6PHGwL9QxsQcq8hE48etBbo82gSCfVgyuOSiI3yfwiBnAnG/aM9qJre1mZOg/5Tw9viPcFMtlh4vCTQM4VTUjPxJFFpoNNd63GInZLKvphzSmI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707337903; c=relaxed/simple; bh=SwdeOXExaKQGPJVJ2NaT/lednGj9CW7yt27zl0ck87s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ecfLvRA1TEPEQhSQSWbXbCecjgtRQ7W0AuPau8kYu3ox5XFJSQtB0Iv7z/aaG8S6ePyd+ZPi+u3B+VWZYRfHLxsHVhG8S25syQbBrWErKYJKcsIBCESnUPI1r0D5lr5+SS1MED4+jRtiQujQRxFCbA5JJ8HgRtv5aWj/aJbI8/4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XdziAUn9; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790273609312279302 X-GMAIL-MSGID: 1790273609312279302 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: 198082 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2488991dyb; Wed, 7 Feb 2024 12:32:53 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXgQaGO9FHADxoiqXgJ9ZL/MOyHHXYj6RRWI7lK++xqlnbvHDjKS4rpCF5o+kv92qPOtKznygGCYFVr7sdsvZBiIyvJug== X-Google-Smtp-Source: AGHT+IGn96F+1WjsfbCCaoEAlQ0jorOy69QOAfK0iztHUoYsBCyJzLJ5wapS8SVKZ8NsayLMymW2 X-Received: by 2002:a05:620a:102e:b0:783:c7c1:3814 with SMTP id a14-20020a05620a102e00b00783c7c13814mr6664669qkk.26.1707337973520; Wed, 07 Feb 2024 12:32:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707337973; cv=pass; d=google.com; s=arc-20160816; b=Uo9FUam2kHu33aAdd3D6zoCl+Fk+0rrIS+y/PrlnblVM40jSnlDusgaM32ysjuJ6Gr cPSW1bCbc2Nynl6suvFcnBo3CoqPN6T0FONcFH8um32ulIlq8NTCkFdLzLiUdAJ4Ezg2 FDcwFG85A2A8OdFAN0FgdQMkEp14PSj6dPOuooHUz9S/OG8QK47WyMO3iysRtdCs+cp0 UKPw/srxaaIp0s9WISI0jtO/DHD2sYad3JT74dbiMeuvCV0Be61rlNBO4qYyzoF4i8bw tlqmBLW8YqEb3+gZPhljnmj7yx/yLnEJ44eyWNCrwmRKF0O/GhJhb5xm7mg/cI7/bGlO gdaA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=lqk+XrNBIXzsY9QkTuWpsp4fsxkH9nn7jyu/kZayx0c=; fh=iaN+2TB38WScDwL7UpY6qvpZz3IO61gcFp6jh5CY2e4=; b=NbT+KqJipMGTcU9M3NPdgmOAOj7cmOeHYQCnF4Uv7+vsmbujk4aHWZLJiOk/ZNP5l/ hv8B4ZwBbAV3x/jxfQst4aPrn2QTjKjsIIsJD/RP83v9Tj6XTzmsp5JXCJ35yBhXBOOW TOcqAmsG/bzyqeMM9tPIHsdOTC04C+wKM3v2DVI7bgqWdwZ7RfDiijSeCQrFTg4MfUlD E87kAL/R9d9uLlv3m42G+t3mJ3NvKWJQrocYq6cPpADTM2qHmqBh8jdpE2Wma9Et+xr8 qtLJl39jwR9kegHYEK7avit/pgESObJafSvZ9lIDV3VCQerXT4MTDXu/lZpqMzih4EOW H2aQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Fi0iIujP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57029-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57029-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCUOIQx4UEyd0Z35X8Qmg2PU1aCSq5xCbBpKpd0L8mFC9Og2w8SpA6YDZfhPohhYKSSVrmxJ79HZxorqdV7wMxOMxajAFg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y16-20020a05620a0e1000b0078437ff3445si1885942qkm.36.2024.02.07.12.32.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 12:32:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57029-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Fi0iIujP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57029-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57029-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4F40C1C245B8 for ; Wed, 7 Feb 2024 20:32:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 78A6276039; Wed, 7 Feb 2024 20:31:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Fi0iIujP" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACF48127B6A; Wed, 7 Feb 2024 20:31:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707337903; cv=none; b=ReMf41TxJt02g82c2JRvTso401EjwAhHDCMVEmqzBMv0pFNs/0pcIiVjTVRLUzySmPRr2IpQTtqX+y3SzQlGU0FGWmIPm7yd8D6UvBRRDmoTa+RGIl0iQYEYvTmN3n3o2+kfUa0xd4MYc30bbq/7+78CMaJ8fxFEgToz8UouPws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707337903; c=relaxed/simple; bh=9lLmi3bov7hQSKSz6Wm19r7FnAY+g94q4B/k/Jgsk9k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZFGEBVLFnu2VjfV2vR7xw8Js9krah8gzCdvnU/21bDhhF6bgdNT7FZHAVAjSVrcmUXyFg/abJ8M+otrhYKH7U5DSgq+lrXUqIV7qIrrdNZQFFVFhjKrH5mnF/rQAwg08RpS6cdFhoZC+J7/cPuyw+MBG6YCq5l/0Z1UQ3TTiErU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Fi0iIujP; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790273623112109056 X-GMAIL-MSGID: 1790273623112109056 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: 198083 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2489099dyb; Wed, 7 Feb 2024 12:33:10 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVT2gqT6ED3M/J+kaFQorslBHTnEncocPrfibO0NyTs/5igZKKYzOPtO1Eo1BGBRtOY1U3Sy9waSXrW+8KymUJeQ9A/IA== X-Google-Smtp-Source: AGHT+IFYFpWGWaA9nEkxHcYBsqmNVJvwBvUC3wrxtQcNbLpjYr2qHSE+Stip27e+qNtYr4JFOgor X-Received: by 2002:a05:6512:3da6:b0:511:5fc7:7b84 with SMTP id k38-20020a0565123da600b005115fc77b84mr4439534lfv.59.1707337990271; Wed, 07 Feb 2024 12:33:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707337990; cv=pass; d=google.com; s=arc-20160816; b=FXZb3XLvKdCTU0PGE/XIgZCOay8LIWiNqi+JUEJINIfc5eXd02UUAaSmDp8j0zsj2o dXiBjLzb69DY2yRToyTPzGv2KYVyQlfKRwENfLIfPTnrB4amsQacV90vjnSz/xuaDzTL Fn/uaHFgEaAOCBv4qdeqDp0cjwO01un6bcnK3xtIZGMBOJlBCOxBxJBd8X6zk2AgF9Ag crYx01tgEEf8D66eG7oO8DO4ed0lkjdBdY/2VyQgZkSv4Uurr2CnWDPphZm6G+Xiab4P U6j4UGGof3GcwKnVsLCVBKB4GR5aKFppYMTveGmTZTu2vLhaOWioZkvrxY+5SChbC1cB 4HOA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=HQsnQiHECGwZ+IIGXPseCKHddRHgG9/ugyekSKU9W1c=; fh=KSXGIq7RP4at3pKjS9umK8kOrP1BToub/FnISto8xo4=; b=qJ12gKLMvqTCoDB+zU17i7h91hC9j3Rbj0fR7TO2IevWId1pci0GpzjxXbX/makMQj 10qiGanxESbkglXQ1YWJrZTsgnC/Kglz7blxlmRCXEZYAnKVsYq5aZBqWh4blsUMNA9F A045I8eAkVQvmY6X5xPCg/YnOHmn8ueLKJLfuNd2n+MLGA+s8tfCK/zpuYRsfXX1JV94 a2HZa0/nLMLCQJDqAgg0lOP9z55a2b1IR0d7BonjuX6eXTB2C8Vr/2/HhxxjMe79DCBC 2pc9qhkErZWJPpDpraDK0T+7zDCZayADRsA0ofsJV4N4c1HwlwuPzrRPalaY8gIz5495 higA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DJJijCfm; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57030-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57030-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCXNUt0zA3W7iMknD+5qjGpIMjyoqhxdAwPw/uupnN+je890ODIm6JyD0gM1Akcc0lPSE2ceeBB23ZCSkPUo+AWG0pjmUg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gg12-20020a170906e28c00b00a386d2c9e06si1248031ejb.487.2024.02.07.12.33.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 12:33:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57030-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DJJijCfm; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57030-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57030-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A8FF01F25EB8 for ; Wed, 7 Feb 2024 20:33:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 48A1212B179; Wed, 7 Feb 2024 20:31:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DJJijCfm" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7903012881A; Wed, 7 Feb 2024 20:31:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707337904; cv=none; b=ITU4Vo46XdOZgVOjjUCowmSgklietYGtXcOt01sLPG7/v2dPeR0cp9wfA/7Oq4cZ3OsqleZVpvOD3cRq+mXP/QuKueSF5mMDX2acYGlfPmLkBDgq8OVOWdQzYanHC022gJmpRUGYXS3i2j7KAazcFtZ/aGVJKpndxBEyTdz0ex0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707337904; c=relaxed/simple; bh=tz9uTb84Z42Yizp5Acw7rjIK4AMaxjqMzKQOqT/pm1M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=N/7h+7c4CkVjmy8ecwRqas+Ush5ZWxiMb1lKWqmF+9/PUkOZ9CVkSqFbP2nGMqdniYJiokikrGLMB/WD5rhCsogl5tJ6E9u3NPkx/AqoNRNX8sN7jct0hmmxQQaAdGZaVssytySOhgmwKt4uAfM8w1RxaSl0t6pfuqWPqongbMM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DJJijCfm; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790273640748914065 X-GMAIL-MSGID: 1790273640748914065 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: 198084 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2489184dyb; Wed, 7 Feb 2024 12:33:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IGNNy/nWGSXRqkKSaIMtaZ0TcP9+DJHfdSiKCYQeP5pd8pUtyPkQ29Mi4VxWuxe3EJqt76R X-Received: by 2002:a17:902:d2c4:b0:1d9:5ef3:e5ea with SMTP id n4-20020a170902d2c400b001d95ef3e5eamr7242205plc.50.1707338005958; Wed, 07 Feb 2024 12:33:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707338005; cv=pass; d=google.com; s=arc-20160816; b=koxMhs9XDw3dhB5TRhsznqJrNoyxj8rjShcpG7NPRppfYrnp+pybnZY73S0KZW7Hwa P41CeulhDK/HjmOMSM9+CwehcuMeYaZvCEowtCPPuqqCL2EcpdMyx0Sr4JEDMiGJ3uht pqZD64rmxoXGv1x5eJWUmiEFsFe7+rqH72rmMXslfpT1A+ordArK1lMSp/BWAkocviOW iC3k+3M92b2xC4b1ljrdOWlXhV/zR1gfakz0/hYYofpuAJLo7HAOLKwAvRySzS28Vep9 mp/f0a2FEJOulGM/fcF3V4eLsE4gT5AgbGVzEzjIplVRjkcOnNDwdYuRxEn174PVYtcS pOCw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=TxVl+5+Ve/BE1UaSuZaYB3tpzYwZOtnPjXlc6UL5oTQ=; fh=THE7p0/r86XGCbx/chOKvWOOBBICQmDdp5bPU9m+/10=; b=VA6CjnpvQd8Rb9MHaaAfchitHRTZek4v6ypJ4rs/GbaI/rD1JBDnlbqIWb0ijuYQ6z vN5roQeK+RopbHdMhhAcGGTkUMmHQdd7Sfdh10gS4SYGWyGU5h7aK44P5YnOHYGbdrCz Rq8TIbKbID5m42BcbUx5wXE1gxHDNgQqiKqqQ7krdfie23Us6IF47b+ygV/5FKSzf1zE XEdopMixrl/abxKHK+39834Q335O5i2SV95QVUIQhMyK3ZBCV0ZeS6A3WE2WfPY0tUxe /TvQ+6icUwz5oxvLSQL/ZHbJFjdjqonOvZHCWooJ8movnEhu6QDT8+9mr7sVuaDMXATI 6EbA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="JKgp/zT8"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57031-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57031-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCXo8lPCQEw6JEU4gep4d27TWNbY17MZcIkYH5J6eAqqzNPQCrrbhiWnjCjqNAcvDm9xqUn/c/eVAtUcG+kqCGIhULqVlg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id z11-20020a170903018b00b001d8f7d2a3fdsi2544214plg.321.2024.02.07.12.33.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 12:33:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57031-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="JKgp/zT8"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57031-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57031-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B7D442856CB for ; Wed, 7 Feb 2024 20:33:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 552CB12BF28; Wed, 7 Feb 2024 20:31:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JKgp/zT8" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55337129A68; Wed, 7 Feb 2024 20:31:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707337905; cv=none; b=awO4IAA7rrCQJGXGv+rhbdSqduL24SZfTY9EHHeof/iAlJn40jU2JviX8innoJbCh9Vu9Tw5MQKhWmS3Ceql+i08C3ul7ph7W5ml9UJ6zYxmXPHcfVlWmXbmbl2xkZsAm+vQJ9+s1QoJhxEass8L0P8EZf9Rh0ygQCJhH+DqNlY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707337905; c=relaxed/simple; bh=eTfAT8I3Zrsng6f7SuRxQKWrP7lIEivzKE3OpfIwwxI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NNNZ/v6HpOXAaHXJM3QzUFepWuf/A15ZJo7OyimKO9JELZ03TPL00eWZ+nVp1J+sqOaxyKmllJ3fsQPso9dkFu3+KaNz/CAOiyotME3GfWZF/DDW8THfaW4sWIZm6n3UgVHBVYlL0iPdsssUAWI4G+5qemv5DPXKolLuEiqHk+g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JKgp/zT8; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790273656517730257 X-GMAIL-MSGID: 1790273656517730257 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: 198085 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2489247dyb; Wed, 7 Feb 2024 12:33:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVB7nczrL+EUe8tvRP72pMDa9WKarSxbOjYZldPZIYaHXuf4TNnULzSry8zWUS9vSuErDlaiXk0Zk7SzU3gioVw56ZM1Q== X-Google-Smtp-Source: AGHT+IG2vz1z4S96YSe/sY/RMJq81m2iDIGedRg+gLnWKaDDJ1u7drnTww7q92vXsWZXLOWmNOZ3 X-Received: by 2002:a05:6a20:a20e:b0:19e:4c43:3aa1 with SMTP id u14-20020a056a20a20e00b0019e4c433aa1mr4890903pzk.39.1707338016655; Wed, 07 Feb 2024 12:33:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707338016; cv=pass; d=google.com; s=arc-20160816; b=ho10dQYiygZv3LU3qevotVd7iusn+k1QMiBrlbdKfr1grX17gwWp3/FV3Ikorxtc1H GIXOEQZ4FCvR/I/OHBFCxKcZX+upv7s8jmdoxTOxHc4myawwpc4Rmsq70WKa4i34HZUW Sy65KxbkN//UqiAOOVR+FdweEG2tH1+9t+9xuqKzACBOtkgGUCHDlYfuW6hv+o5elxQe 5fsBAt1baOdtsho2LcKH21ylX0QFLX5WPpFSvZT5PuNvg1UZGXzqDY24agLgtURS9u1Q JLl+Ju22gqvXxRhrTQeLU7HSuT5xGbW8+Km8LrwLqwpn4dhtakG/VBnN9NVBMJfns6CA Vr0g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=rqjq/CwbHCXgPEB18xIZCSBiYr8N6Pvdhm3Ak795qwk=; fh=wOBZBW5q6BoG8F+eYO2d6ULAOcuwRam7+S2TLEznWHw=; b=UBdTTGyWrzDNJEN4q0vzH0gZxmmu8G8jdJgTT3LPZqGWyCyhh6fXqmqy4D6w37c86S sUlIKW34/7nAQKuJBYYTHti0xTUlug4hhKQWBDo4oIbJi8gyDEmALKmD9r971opocWxG TcUwIuvoqsCC5ryZLS7HsgMdMQo5lp2BNpTkxmirXSlhhY+lIQziAlBfkz31Vubj7E3x 12LEbUZhBXzEZBaQiTtJ2rfsrRHdi/1wAj4/W1f3Tw9ulemm4e9RkUZK8rF/D05Ypb1H 8st9FpAofCMfel4DqFXGsu0E4pSSlZd6xbhGBy0EmJd9MJI32A9EImhBWtVTw0TJLEMD rKjw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Kb2oXTnE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57032-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57032-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCUcVzDvqwUqUmNornnkh0Hfo/k5eIOrpOtJTGMP614Clx8F6TGI8XwGnwel+Czth/Qui1niTTNELJVSQyK5UWtdNEoSfQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e3-20020a17090a9a8300b00295f1aea266si2264131pjp.89.2024.02.07.12.33.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 12:33:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57032-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Kb2oXTnE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57032-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57032-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 704E4288A14 for ; Wed, 7 Feb 2024 20:33:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0622912D168; Wed, 7 Feb 2024 20:31:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Kb2oXTnE" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E522212A140; Wed, 7 Feb 2024 20:31:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707337906; cv=none; b=l1dbTGVfBu2+1H2SdADQKFQ+0yDcgWYdtyqPzQropeIJ3f4hg2Yx6VJVAviTZZgFT08b/PSO4XqDM34DNo0HO+IvmANdfLaDaYIBYFij20W1Rr0jtuIAee2ZWaww5t/zF8aF4oddtbaxVBzGqNfOawwVPUorQm7FUFnz0gDvqns= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707337906; c=relaxed/simple; bh=S70M2GZNqYMqWcESwYxGcEzhW76DUgm+kbbaqJbCpdk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LeALtH/y1Xj2C73EwkSpgd+DaoRE8hKm9cFnnLDIJAFPxQXmJbdtgo+/sqoM/yvEk12M0dE+jkbpObcxwz5pYaEPLUMU5UraTM/536O6QNYFS54aY9YCVzDp9bEkqW5d9AyH+btsSn9P0fhs8S34WYkLAHynLHh87ELKjyBn3/4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Kb2oXTnE; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790273668053765185 X-GMAIL-MSGID: 1790273668053765185 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: 198086 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2489318dyb; Wed, 7 Feb 2024 12:33:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU+TrjmQjFj5Fdz6TvDnp+ClgK5yyYIb+PuJgzznukuYpLmdSw1TgkkSg1rCwJ7jnDw00kapFSEtt8BD/Uvf6VbEBhEJg== X-Google-Smtp-Source: AGHT+IENsCS/VVbLRABN5hZzbVMZpS61G0MZfpqBmXBvJvYn4+LLGe5oZ6IvoXClWZyhaOUJ/PIW X-Received: by 2002:a17:902:cecf:b0:1d8:e64d:cd62 with SMTP id d15-20020a170902cecf00b001d8e64dcd62mr6980565plg.4.1707338026230; Wed, 07 Feb 2024 12:33:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707338026; cv=pass; d=google.com; s=arc-20160816; b=xP41QJtJUnG6n1Jg1wWfWDOo2VIHZKzRuNH7bpsV2IMWjnHdeNXBL8H+6Q5eRA/f6/ awW9kEACZBYF00uut08rVgaRRXjWBKMI/lyDsEzwyhpfEZs9JS8dC3djEUHhKQV73WJh nCX0hlWv/Ql5veRX8BMbB7VPLc5dO9gD6Rn2+2kc1zATPUThiqBtz0jMZ53Ov5r0npIo L6cQPlf8i5XEA2O9hscjTpKz4zEx2P2T+vVav779tbbETPFT7Q2NNad2fOA+7y/0Mk0m 23nBHdc8cW+i07NRbIzbeiGHYpLhQ/f7DOLQTXjusQ7GsPUpkWs+OjDVrGkoGei01i4P zrhA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=pEYzds38qzJkO3LwswAGZ3BaHAxTO2WCf8jM4flPQbg=; fh=lTvATMfFI9L5JpsE45ETF103Innb17eC76WeXhXhH6Q=; b=d1J9aLdlILsuh93hZw9mVBVbiLsp6GM3BdpaBq4smVrqlA1mKswIhi1Ete4Vx3waZC VWledpUmRxOh3Ms27DxaQt8XdKjf7lG8A4CEqbUlTgn24taJVIDM5QuY2AJZGDTSZCbh Fgy5xNjB7dDQk+q7nZlxyvmnt1B/HHQNW5ac8vqWwo64aGRCPD3p3tbYjSqNz8SfLAjT 1nggFC1jCqYvA5CLsqOY1byIy5pHTyS5Il7DEN+O7lz+86LJyoYuVglrNsw8sAq/mznk QuRGKvJ+uNfSS440eauM3WG1jjb1D2Isai86KJNTTyIY/iYyzQVUKT3tqj1WC9m1xE1C duzg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ou2UWhF7; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57033-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57033-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCUPLxHUI9J8RBlEBl6M8u4HMoZTrR7ToM9Vy3bSJIUviEM3TJWJB/PTa4UYVJiYZ8bJMwYdUTT4v2xO78o+KL4EAKYFfQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id c1-20020a170903234100b001d76ae4c927si2539553plh.10.2024.02.07.12.33.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 12:33:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57033-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ou2UWhF7; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57033-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57033-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 06B9828E4E7 for ; Wed, 7 Feb 2024 20:33:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C72C31EB38; Wed, 7 Feb 2024 20:31:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ou2UWhF7" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B668E12AAF6; Wed, 7 Feb 2024 20:31:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707337906; cv=none; b=FpN/Y+Dbp93F6yCbjnWwAonJiA1I6SgiE84hsOYbUTu8YFg9mu8LMLJo1usvpT72/CypjwdJg5gaYLVAYFtRXeuGmLlvXE9wgM07j4h1Cafb2s/E9JkjASsCqo5sFOsJxnAPKnGvOeWNZlBJSTTT1a6uzjkesfx0vYjVrFWnul8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707337906; c=relaxed/simple; bh=hilY7j3dbTrTcHQNZ5cH9hllN5vVoaZDnsr9bRpaZZI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZBGxHFtfjyI5itmAHYVftt62DVXZP7vD23DVCBbnsVI7FkImex4WfYF/gPR+X+EzI8eOnlCXa7TUGsnoH0QhwYR4lUwnWXNREsXEWjZPiDBkvG5jdmygQJawY0SSOcY5JUiIsa6z3B2INiZUIdBqmpjDrzvy3C1qGxeUNCGBK+A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ou2UWhF7; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790273678123166643 X-GMAIL-MSGID: 1790273678123166643 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: 198087 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2489358dyb; Wed, 7 Feb 2024 12:33:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IFETJpRuzsDQ/IS35/PWKFmeApPXPYW5d7WsZj2010kydIFvPNpip6pVwm3/a4hTIjzfrW1 X-Received: by 2002:aa7:dac5:0:b0:55f:f41a:2484 with SMTP id x5-20020aa7dac5000000b0055ff41a2484mr5356572eds.37.1707338031625; Wed, 07 Feb 2024 12:33:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707338031; cv=pass; d=google.com; s=arc-20160816; b=CwhOZ7/OP1P4iukcS5su6vEpOsw1sBoAH3W0JjSu5kK3GaKntG27gUuZlU8uI+k1hQ GntXrqI33pP2pcgGakplBCO6+dM1cvhvtqMup/yJvQo10HQUrAPq+pD4qrYDUVueygzP XDbX6lPRd9IGtkh7KeZrgeAXxEKjYvkX8lYEZag5TTg5CzszmUciNht6jL09p7O2yq1Y UMFGKLLIM4SayJHyKl0x+hK1E1X/s4/x0BcMbx/6mozWbb/IQwtYlk2zZ/v4DBLoL/1h hbuWrMtLw8G/8+mbCXeXrlrI0d19USJg3SKcWH0dQzGCJddHtIPMu9thY5saxu9xDZlb gQUQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=fX7x7KF5C9VADl9D4i1WzsxN5l8ADYMGFpSB6bu2YWE=; fh=TU7kRMdBYG3g9CXP4mtOpGTGILiit7zafzz1lCFGWZU=; b=f+JcSO3d2Jg7OkagP/PmMKwq4p51GDqvxdLeWiI+NOJzlh6jScm5xu/BRBo2eGY0qC vTmhmuOScdYMoqXAqSt6O3Nn40xTCQku2itCkJUcw+GCel0ayeF+X1/LVhIKu1wOJmCF fDG3p7l6ouahmaI59nAJtn/RlRy/l88sCIQZwYv6OWWTlcO4au4SJUHliX+rPppM+6ld EqCpLlYxdryxhHavP2Jh6a5sQY/Dh5/oy4ikFRhcvSkOGAsusXAI5Qh0vRuZ1bhJxq2B dGlr5vyrU9Gj3DF/lCWMLwDA7Oy56WAdzmLG9nvkCmASbKTQc3ztvyFm6FNStOB153xx Iziw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bZjKuePx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57034-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57034-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCXQ9ywR5046xSbJi3xooUbKlKa/wetxApFZXCFvM+muQv0nDVFe9VzvFAQAVTPTdPVccUKaIFEFRCaYmb5udEIL1Sid4A== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id c6-20020a50f606000000b00560a88b3908si77143edn.94.2024.02.07.12.33.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 12:33:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57034-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bZjKuePx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57034-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57034-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3104B1F2609D for ; Wed, 7 Feb 2024 20:33:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F6FB12A15F; Wed, 7 Feb 2024 20:31:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bZjKuePx" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F23512B17F; Wed, 7 Feb 2024 20:31:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707337907; cv=none; b=Ld9jZNUPmjqGaUia2x5O3i7BSZLejcelEe9MRHOibqQVs0VtZgQROFBSZxV9g9BmEjQFar9DQNXqUCWQF4zO0v4okCMOHHyz8IJlMeg0DuYO+xPIvoonZXW4VhXpITWodXkSuRlW7Pipq2qhdo5SVw94iREazeEfTTR2YCm83uM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707337907; c=relaxed/simple; bh=bo48Sw4QueorxjSh+Ck9B6Mrnc7pi7WnA/Re94O6ZTo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UkGcCbrRz3Bmwg9aO8HjpxCS5sKst6esVmfucd2uAw28n3x1loMo05ivyXZzxat9uCOAPgm3W1Ja6aY66E9INT6FMP/3MXBzZ54uUQZPIE9OmVDAsjpF5e80ChL0I1nmop6eBjPnyaby7X2yLGCzReWu8pAXxBCQ1GLrkVNaWIg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bZjKuePx; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790273683602461113 X-GMAIL-MSGID: 1790273683602461113 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