From patchwork Sat Dec 2 00:08:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 172726 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp1495625vqy; Fri, 1 Dec 2023 16:11:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IEDghEwdTUkoNMjIOCXTjbQXBymBgYHULg33KJZ/40yCD9CBmxKwxy9J0yVYO2HgFLPj2jy X-Received: by 2002:a17:902:c412:b0:1d0:5efd:7594 with SMTP id k18-20020a170902c41200b001d05efd7594mr259217plk.27.1701475864816; Fri, 01 Dec 2023 16:11:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701475864; cv=none; d=google.com; s=arc-20160816; b=n/fAXBl9ScgH4LdY/9XXbBJbHJVuf7b1rhH73y9m4gmEEhusNrpfJOvH07odgfUeJl FbhL9UE6TS9WizZSkcAmXo5/4WZwNhwgRaV9zEyBOeLtzrYdI7nipw09O6NHdZGyen/T 85HRLDb85k5dKdpcE/E1ok9SGvWjgxF4IxLKWJ58sCHiyIQ25fN6ZHLhnXksL5G9Xtic v3RS3q2K2wEjErhSrXCQb+/vXUM0+RxDJb9C+IKZ4AKttmFXMDUy3oR+GQ5It2QToeDA wyEBJdq/Czh2tPyqHWPhzH4H5iUER1SMRr1QgdHnXLVRhDeB3rmbPahi90FwxHckcJwS wj3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=SFjOn3zCIEsHhiaspJ6pQfeVLQd0iPHQgxP9v7/t7xw=; fh=W+de0FjxL1MlRh6Ly02q9tA2/xTz2DOJsg1VkI/mHfI=; b=bYOOANgNGjATZi6JyXWp0ecMgzqZGtS2O5d8BVuAi8wPyYMojogBilUpvY3wQD9aip brC7zpw1wo3lc+GKKsdqYUONgXb1Up5/776XqH4BLGX+XGP+xrY+lEtmoi9rwO+lXkEX bXA+Ggh3ot8dFh3FxAxzvDFIYj87mpeJc4HJ1MyyGJDjJ9T/C9+hsC1PP82ZeXWrrOeS GCkSYiGm3w0puGcj3xnz1Zc/EaZncNVpvFHfEAOxUK7zhP6MJZc7Qb1pkCBLKWA/7d3T dedmoeMOD0d5v+JxOIZenmZus6z0ybo4BO2N1++7/L2WPTOizUtKDlmvE1Xfmef9wXwm 4Dbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=lgHf7Eo3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id b2-20020a170902650200b001cc2f9d6a66si3962993plk.514.2023.12.01.16.11.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 16:11:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=lgHf7Eo3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id B9C7280713F5; Fri, 1 Dec 2023 16:11:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235363AbjLBAKy (ORCPT + 99 others); Fri, 1 Dec 2023 19:10:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235389AbjLBAKg (ORCPT ); Fri, 1 Dec 2023 19:10:36 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45F7B2D41 for ; Fri, 1 Dec 2023 16:09:41 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA99CC433CD; Sat, 2 Dec 2023 00:08:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701475693; bh=0o1OidTQa+jBmmayVqOJ5Gh8ghc1rg4/WI7HWKTJJqA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lgHf7Eo3aY6hqilQ6vhoUxZZ0Dc2Zeu3gG4+W5pxm7RRYGGlX6sRPfdd19Ii+dGRU 3b9OCW1b8U6a+3cQY+1RZWwDJqfWWXvPCDWx/MFMLLBT0neQjeR8jtY/JV+Z7x03qx dYbsUMgMGYcmq39jD6IJoUmkxwT4DwdLsNjOBAXOkWcfOuei2nWCGBKrbOs8JoIrY4 OieJhlPmDjSE47hOJ9n1ygykcGnoQsGp/C/DuZ20al10JgSmXbU7X+xkKJOxRh51Ie kBxeDsvx0mPcaXCorB5l6mp4p/vYCUQ0vBhkwzggPNMJ8/arJWGiklqERGlbq77zk6 3PXJSOLrvCU5A== From: SeongJae Park Cc: SeongJae Park , Andrew Morton , Shuah Khan , damon@lists.linux.dev, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 5/5] selftests/damon: add a test for update_schemes_tried_regions hang bug Date: Sat, 2 Dec 2023 00:08:06 +0000 Message-Id: <20231202000806.46210-6-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231202000806.46210-1-sj@kernel.org> References: <20231202000806.46210-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) 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 (snail.vger.email [0.0.0.0]); Fri, 01 Dec 2023 16:11:03 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784126756703766255 X-GMAIL-MSGID: 1784126756703766255 The update_schemees_tried_{regions,bytes} command was able to be indefinitely hang in some corner cases. It has fixed by introducing a timeout for the command[1]. Add a test for the corner case to not introduce the problem again. [1] https://lore.kernel.org/damon/20231124213840.39157-1-sj@kernel.org/ 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 1363987709c6..d90bdba28ff4 100644 --- a/tools/testing/selftests/damon/Makefile +++ b/tools/testing/selftests/damon/Makefile @@ -12,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 += 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 TEST_PROGS += dbgfs_target_ids_read_before_terminate_race.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..14187be3b004 --- /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 + +def main(): + proc = subprocess.Popen(['sleep', '2']) + kdamonds = _damon.Kdamonds([_damon.Kdamond( + contexts=[_damon.DamonCtx( + ops='vaddr', + targets=[_damon.DamonTarget(pid=proc.pid)], + schemes=[_damon.Damos( + access_pattern=_damon.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()