From patchwork Tue Jun 25 18:05:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13711793 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B999C3064D for ; Tue, 25 Jun 2024 18:06:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 094AB6B00A2; Tue, 25 Jun 2024 14:05:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F360D6B00A3; Tue, 25 Jun 2024 14:05:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D84CC6B00A5; Tue, 25 Jun 2024 14:05:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A37FB6B00A3 for ; Tue, 25 Jun 2024 14:05:52 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 5EA7DC04DE for ; Tue, 25 Jun 2024 18:05:52 +0000 (UTC) X-FDA: 82270189344.21.2FFCEAB Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf28.hostedemail.com (Postfix) with ESMTP id 92A80C0005 for ; Tue, 25 Jun 2024 18:05:50 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=TTmsSt1L; spf=pass (imf28.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719338739; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=YTiFptegXC0rppC9bHqrhYBnewbj0+nicoYYTPan1WQ=; b=r98io+Q4ZycCacXPLB6Pd0GTOTmTyOc26wH/Kc5s/hsyYAEIA40M0DfJI++egsE/pC1a65 8jujLZ+O6S4rNpBkafmfA0qU+IlBPkut49RsiHGx5vUPdILmtBS/3KALuQdQqvwpvNPFR6 JVepcTS449Tqcmh4wSf/E/AwMIH+c8k= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=TTmsSt1L; spf=pass (imf28.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719338739; a=rsa-sha256; cv=none; b=QzOlAqHhxRUagFInYNNpUKQiXJD1+hWQj8iLUZBiazWYRJ6RTOLepVqqKSgt7HeMoNOUlo kOd1xCAfJysckZyS2LtwIVEzM4UBkz//ToODtXgtHhF2j8c8j5UfqkwJu/OmIaTTmB+ju3 mhpb+z4F2oce05/zydfvHtcWSvKuao4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 1B90561741; Tue, 25 Jun 2024 18:05:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6AE08C4AF13; Tue, 25 Jun 2024 18:05:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719338749; bh=8dhvoCKICij/0wQGSNgn0SXQ/QZt5ONQbTkFqj9oMd4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TTmsSt1LplYj2gx75lsu0LsLjYr7zpzivWHZeftrLD0ikOQkOY2ldifr5MyonkG9z Uf45WeUIRwFWXiAVVEGIFR5veoTR16qDvL/6I/kdKd4CfTN0aME3VwZCxrqR6zHfAG /1Od2Xe0EHh3kzxZQlBtkIS4/0YW6VU6XoVvZDZLayp0Zhz1s17+PQxhTTMesi+EQp 0W+jIkvNvTobeeMDy23Lq3WZTQnlWOzECqfODDegNv6ji7a+UqEYbzXiGjtwro6t/1 O9AD4ZwQUmrF7MsdNc9208Tb6RHx8CjZuV/eFPf8lacpyPrKP1TWqkO2NyEv5YTbdq 1WUgDBxyxdcSA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Shuah Khan , damon@lists.linux.dev, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 8/8] selftests/damon/damon_nr_regions: test online-tuned max_nr_regions Date: Tue, 25 Jun 2024 11:05:38 -0700 Message-Id: <20240625180538.73134-9-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240625180538.73134-1-sj@kernel.org> References: <20240625180538.73134-1-sj@kernel.org> MIME-Version: 1.0 X-Stat-Signature: 3t1rje4m6zg8e9xrnehyiyh4b6mdppcr X-Rspam-User: X-Rspamd-Queue-Id: 92A80C0005 X-Rspamd-Server: rspam02 X-HE-Tag: 1719338750-588961 X-HE-Meta: U2FsdGVkX19WO1ZV6q2eFJgrP+g16YRTBS5S2XnL812NoW4fDFIRmRPLqDf/tspa0ZRe/3csHCpE+ki+tpsTyjcOq3a1jvL0prw2qp2g18zTSBf70iJ1EcXWaH9mrlDPE/wB6XrG81yTTB8V3ugW+/eId6cPBs6GqsTPAxgCgs74r8d3Vs4NPvxAokkC603q4hG8dqWaDrp4gYFaoQkgPlfMdd+5Hlz4inwBFMBkHCTK9lbpxnGvi68rDk0BXhMofIXdj32sz4fIdyXtDv4kZH3q6zXxnUoo3Sqa5yZ2H+pr2uIQT+W7z8FbD4/B67ecyRnOSl6mH3gAPVeD3nk/PoZwSJK7+HElAcw0d45gKSeldxw6p6ivQdai6RwYxqh7Crf9FJNe+h0pcPg06yCWTQ/kxapPuzkVdpBl5PrD59ncP9DfT9HYsGo1hn1dYCxdZAcAiUakNZDDojJ20RVHl237jD2O0z8DpQw8wBEf/G+zSkA3UkqehAXhvHTpJCxHqPLYIiOfw3rynRXJnTswB3sp0iiTILmQOJ5zR2l+ECp2knQxIpHtlgqI5wDZ3ZQUcdR1TPT4n0gg5hPFBprQ8YkpJTZ3I2G8vVE9elO1099woX+qPWvybNXnk6jp6hzJ2WVg9qkKcF17rCrU0EQfatgiNa67b3AxTzZLWRbU0ztfpcPnpMrByIX9k3oDGT/XJ30f+H6T3lif6LFHjk43aoLTrVgnvtvf/SWR5+TBIgKG60UkMdiyXo4Gh4Cvi7jzcVeM8C2JzdL7MZAqa6qa8+9Y+Ne16prYlORHjP12FvrLmAF026RT4q8UAG6/fVdx2Ntt41XtNlbyHytAQklUB8L7yZkfEs27rjwrZzySURyqtT0MBN1e3dCl5t4ctkWN7ru1E5ZCuo7DCgP+l2vEIxUBoN/D0JsZN6aPaj8O0HoggRpxxw4D4re7cVz2vAtzq74rnAfDz4za6J+UQMx G6YlNiD4 AxMQ6Pro9x0d2+/oZQOsG17eGHER/LsCLqczxLoJECWf+1HfR+DLjYOC1SbwJamLU36m9KlFhZfD53Ess7Am8K1JcceDRRjFHkaNl3nICWKpezGRZQz8xpD6qsqHxXFVYqH6hloQe2UfHGxvp5OsSk/+HZ/FdRUXysiXeV0NTG4oDd459/u1UwsOhKcRKrbwBBf64PJtK1ydo/q3TYK+PzhxROievtxceMR6oGzJNJq/pEmlXBW7QG7tH98t73QDdeFDdrzFATqSxWH4wanD8uNExUQ98KgXuOMZporuu9ZHt+wzskOhIh9YhrkFqsnjqLqqN X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: User could update max_nr_regions parameter while DAMON is running to a value that smaller than the current number of regions that DAMON is seeing. Such update could be done for reducing the monitoring overhead. In the case, DAMON should merge regions aggressively more than normal situation to ensure the new limit is successfully applied. Implement a kselftest to ensure that. Signed-off-by: SeongJae Park --- .../selftests/damon/damon_nr_regions.py | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tools/testing/selftests/damon/damon_nr_regions.py b/tools/testing/selftests/damon/damon_nr_regions.py index dd2735923c59..2e8a74aff543 100644 --- a/tools/testing/selftests/damon/damon_nr_regions.py +++ b/tools/testing/selftests/damon/damon_nr_regions.py @@ -81,5 +81,65 @@ def main(): # test max_nr_regions smaller than real nr regions test_nr_regions(15, 3, 10) + # test online-tuned max_nr_regions that smaller than real nr regions + sz_region = 10 * 1024 * 1024 + proc = subprocess.Popen(['./access_memory_even', '14', '%d' % sz_region]) + + # stat every monitored regions + kdamonds = _damon_sysfs.Kdamonds([_damon_sysfs.Kdamond( + contexts=[_damon_sysfs.DamonCtx( + monitoring_attrs=_damon_sysfs.DamonAttrs( + min_nr_regions=10, max_nr_regions=1000), + ops='vaddr', + targets=[_damon_sysfs.DamonTarget(pid=proc.pid)], + schemes=[_damon_sysfs.Damos(action='stat', + )] # schemes + )] # contexts + )]) # kdamonds + + err = kdamonds.start() + if err is not None: + proc.terminate() + print('kdamond start failed: %s' % err) + exit(1) + + # wait until the real regions are found + time.sleep(3) + + attrs = kdamonds.kdamonds[0].contexts[0].monitoring_attrs + attrs.min_nr_regions = 3 + attrs.max_nr_regions = 7 + err = kdamonds.kdamonds[0].commit() + if err is not None: + proc.terminate() + print('commit failed: %s' % err) + exit(1) + # wait for next merge operation is executed + time.sleep(0.3) + + err = kdamonds.kdamonds[0].update_schemes_tried_regions() + if err is not None: + proc.terminate() + print('tried regions update failed: %s' % err) + exit(1) + + scheme = kdamonds.kdamonds[0].contexts[0].schemes[0] + if scheme.tried_regions is None: + proc.terminate() + print('tried regions is not collected') + exit(1) + + nr_tried_regions = len(scheme.tried_regions) + if nr_tried_regions <= 0: + proc.terminate() + print('tried regions is not created') + exit(1) + proc.terminate() + + if nr_tried_regions > 7: + print('fail online-tuned max_nr_regions: %d > 7' % nr_tried_regions) + exit(1) + print('pass online-tuned max_nr_regions') + if __name__ == '__main__': main()