From patchwork Tue Dec 12 19:48:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 177541 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7963029vqy; Tue, 12 Dec 2023 11:48:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IENdXfNPT3qzxOVgJ2OYBAdhtAACGRbyWSxP47hAP0fAaXTrLe4o5A2FP/wnFawfSZU7Ha0 X-Received: by 2002:a62:cd4d:0:b0:6d0:8892:e9f2 with SMTP id o74-20020a62cd4d000000b006d08892e9f2mr3701990pfg.48.1702410529626; Tue, 12 Dec 2023 11:48:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702410529; cv=none; d=google.com; s=arc-20160816; b=HKY0Nrf9jb4acVcxkkDdxpYt8OiS66fOclgUmQwG/6zir72IG/KvWu9DPZPLSMUOvQ LcMpVXTi8Qj4YBrgiTP6yEfdxwZCKdiRGeXanaYmL7dU1sCtVYYmcubHuq4GIjtjibBU DllS/VuXKot96ASwvBu4mGZWBah/NwKH8WwzD8g1WUWTvClVUbaH/eTcXDoCweJ1rhDQ IA1F5TCz37QToLKhidYrpf9rj+lxAE3hrj1R3YlRXyNtT1uX9NQay64GW84so5G1oNP0 aArTM7Zk1xrHmniGQwazR+NtMEEbdYsFu6k8v5nd8QWxbcHmCcKMqGW7YCuHx4Ne3Uqn Clwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pQbJ5V3NxZOu7OM52vlX9DRPX5ZW4g4hS+7Mx8S3N+0=; fh=9H4z7/o7y4OLn0xLmjdSk9Pth53+ED/R+iGnGlnIr7g=; b=OxO9JzMN7xtevfVPyt7OIGgiykMYze6uJbHXYUVfB9oraL42Eb92sUt6o2lsQBdxDc uJdmUlzgRqexPV7H6GFKF4WfyaKbbBL0icXouLw+qhFjpQCELpQJvtZXX05SOx74f85z Pscp7SSZ/LgG8vZVU4i9qarCHqEMHOOlnROP4oUtHj5iIeIaznXUxc6t4iKXrjXDD6Wm s11Ma4qL70VOSiVeiPoNfpfDhLLVoATWBbvKAGkr2wjzsf1+IIfri+/xYUUcO2B2czAJ PMJQYWS1qeX0J40JJy0frG/mk9faIyjOxZt3QOfLACsR6wwXuNJ5vfpo4BVg1IEYbGnj nYvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tnzxvu7B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id c16-20020a63da10000000b005c624fdd8e7si8102769pgh.727.2023.12.12.11.48.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 11:48:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tnzxvu7B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 0F8FA80ACCFA; Tue, 12 Dec 2023 11:48:47 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377318AbjLLTsa (ORCPT + 99 others); Tue, 12 Dec 2023 14:48:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377284AbjLLTsZ (ORCPT ); Tue, 12 Dec 2023 14:48:25 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AF91FD for ; Tue, 12 Dec 2023 11:48:30 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BE7AC433CB; Tue, 12 Dec 2023 19:48:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702410510; bh=oqY4K6jG5BE7MOa8w7xZ5OE+AG4WMHalMWId0VgXocY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tnzxvu7BVIdvv9Ic+qurUQy08ciyvLKjizQmFRbi04fR8a3sqd6LqpKeq6mcwP8Zv eY8cV+zJH2kwV7qi4LahoFIcN6NrYshFn3VFzeTRsSaFBX1dabyreTm1nT1+HBv1GC ZnNAHfBSfmGfvpivfX7vkQPeAH/oaxqWKKV8I3s0HzfGGxwSQPV/XYGGYkCmjERBzT 5KPrWUvNUwetqb/syAj2X7gA6u/ovpEZvvE+CbPXzeHzsPZxyuFCPIkubXJ67Wh2sT 9/6duqy8LuyB7t1zMc27sMWSH0zgFXE3L196jMplrgOlGxLivrxPKOBgWnMkbQULsF nlhSNbD+4hbWg== 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 v2 5/5] selftests/damon: add a test for update_schemes_tried_regions hang bug Date: Tue, 12 Dec 2023 19:48:10 +0000 Message-Id: <20231212194810.54457-6-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231212194810.54457-1-sj@kernel.org> References: <20231212194810.54457-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 12 Dec 2023 11:48:47 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785106823390375303 X-GMAIL-MSGID: 1785106823390375303 Add a test for reproducing the update_schemes_tried_{regions,bytes} command-causing indefinite hang bug that fixed by commit 7d6fa31a2fd7 ("mm/damon/sysfs-schemes: add timeout for update_schemes_tried_regions"), to avoid mistakenly re-introducing the bug. Refer to the fix commit for more details of the bug. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/Makefile | 1 + ...sysfs_update_schemes_tried_regions_hang.py | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100755 tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_hang.py diff --git a/tools/testing/selftests/damon/Makefile b/tools/testing/selftests/damon/Makefile index 90ffafc42c5e..8a1cc2bf1864 100644 --- a/tools/testing/selftests/damon/Makefile +++ b/tools/testing/selftests/damon/Makefile @@ -10,6 +10,7 @@ TEST_PROGS += debugfs_empty_targets.sh debugfs_huge_count_read_write.sh TEST_PROGS += debugfs_duplicate_context_creation.sh TEST_PROGS += debugfs_rm_non_contexts.sh TEST_PROGS += sysfs.sh sysfs_update_removed_scheme_dir.sh +TEST_PROGS += sysfs_update_schemes_tried_regions_hang.py TEST_PROGS += sysfs_update_schemes_tried_regions_wss_estimation.py TEST_PROGS += reclaim.sh lru_sort.sh diff --git a/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_hang.py b/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_hang.py new file mode 100755 index 000000000000..8c690ba1a573 --- /dev/null +++ b/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_hang.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +import subprocess +import time + +import _damon_sysfs + +def main(): + proc = subprocess.Popen(['sleep', '2']) + 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( + nr_accesses=[200, 200]))] # schemes + )] # contexts + )]) # kdamonds + + err = kdamonds.start() + if err != None: + print('kdmaond start failed: %s' % err) + exit(1) + + while proc.poll() == None: + err = kdamonds.kdamonds[0].update_schemes_tried_bytes() + if err != None: + print('tried bytes update failed: %s' % err) + exit(1) + +if __name__ == '__main__': + main()