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: 13476688 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 9FD02C10DC1 for ; Sat, 2 Dec 2023 00:08:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 454CD8D007F; Fri, 1 Dec 2023 19:08:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3DC4B8D007C; Fri, 1 Dec 2023 19:08:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A62F8D007F; Fri, 1 Dec 2023 19:08:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 1AAA38D007C for ; Fri, 1 Dec 2023 19:08:16 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id E2045803A7 for ; Sat, 2 Dec 2023 00:08:15 +0000 (UTC) X-FDA: 81519940950.14.F052C2D Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf02.hostedemail.com (Postfix) with ESMTP id 47CCD80002 for ; Sat, 2 Dec 2023 00:08:14 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lgHf7Eo3; spf=pass (imf02.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=1701475694; 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=SFjOn3zCIEsHhiaspJ6pQfeVLQd0iPHQgxP9v7/t7xw=; b=N6jjsIw0jhtOdcrVXyGiBWtTxvEeZH0xxbFT8DDuXY8mMS0L8nckL1lXQVn4F9ckyvibA/ y607fBrD/MHTteIao+1uW9U7OwHOlnnIx+q+Uk0BS7F1UcXwGaxdfI7+WnsY3NpU/iriKL OdL248u6vkclcKaGpcbXrKn3FD9xs98= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701475694; a=rsa-sha256; cv=none; b=y6U8nUQL+SsuvUmeDraDZolQRmLqUxZOgAUhjS+O17zxKXTzvp0L5GD1QyNh6/k/tuHzrC WYB1HfoFylU6vrWQQXUR6xkJYWN5ZRrxjxw8OknWRFiSSZWVdQ1WZtN2qT+Y1CckdMfuqb RkKcfl806F6aw6niT0hIDvV0Tu471DU= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lgHf7Eo3; spf=pass (imf02.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 9574D61761; Sat, 2 Dec 2023 00:08:13 +0000 (UTC) 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 To: 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-Rspamd-Queue-Id: 47CCD80002 X-Rspam-User: X-Stat-Signature: ubfqmno5rdyqihuu9enzmkdyu6erzbhn X-Rspamd-Server: rspam03 X-HE-Tag: 1701475694-941355 X-HE-Meta: U2FsdGVkX18jBeDLas6LgHTxiJ1PTB5k+ZBSOLQA44KO4OTNhF7wcTRq9RRJtsjq4f/5RcSJqkkfnk8Mey1JBL1E8WPQhnIiSBmsu9Pgp8HJyyLW/QMxZkEyKv+GeS8cqqnzpiYjLaLAm3dZGCZO1XPS87QXO0lXdERAHV8w/ujF8GKFtJaMgQZiDKOfgmwuYXp0BpBBv2cgn7a1voPuumAxxSz6cz0RTrESwAuU/u/Hj96cCktqnvp9Vk/KVbz82vQA3s5YcoQZvvT4NLHENiDcnfIgZb++xZPJDoJdoMFy8zQMC/eA1vu9gdVOddaSg4603sBVWZhnjZKtR6su2ci1GH52z0ZY/bzpjfL2n4SMnR1Ej3sqZzZleGgTm9Ycd+vviYdfV0oaLLhLhpMrrROBXApnOnNc7H/xjc2buWU9vBBAP/SHlIeFfxzqywcDw0nYzbT6G0Xd1nlCLQUwCNSAARmNvuT/3M71rxzpwlNDMRAyvKfIe+Qiy3Navt8O6VcWPkwiMbxBtmwOlb1ZTeiFYjQf9NwOgFTcP75h4Q3U7VemRSs0pUYDl+6RmYXR3kP6pBbyqsC72WCEndVhbzXPhSXtGpn5daHVDL29e64hGZgPBGQY5jrS9AZGBotfW0Iv9vichULCMzWQyYFmKxfd3anmTWjJYFIzwsIEUnf9Y1eYylMW8M365GqtQbwHeqXDs5ZEmW+sb2mm9M9xdsdUQR1YA41GLW0SGCPVze0s60v8iy+e5SMrZdjBdQRgtgKAgzWijEkngqbAAIz+H6ZpWXXppsWXzQP99micPCl3dLv8nrFrfaGTy3Mo+7dJhZS9Z/pA2ottFMnwoC/7P1Ggc986OvMRleY5QVkMsHzo2HEetugb2nN8VFTehS79xhrvr83bcdgVmynKYxA/ycPbmNBNG3loFgitXbtu9MhLoT/zrkKcxSM3k0VMsKLtRofUk3o7BsY9T/n+teU 9j/hDRYk CicPd2hu8HIaiSaVGJ6FWXhwPd6wEGY6hm6pUtXJkdp6zB3M8pZeyvsXyFVebTszz7avm8Wvd/GcPeRiCtB8ItlDP9eyXXXg3W5nWlH/tzC17AtX/OWTFojzSatkhZ9Q6Xk/+uW9wkrny9i0C3F364utJiij7Jz9YvJOtMofAOoeNiwe/bqq0nMTGGiSuNQqANtcOtek6Ag847hFviOe8ihHodHVlNh+096BZL216hFX4D7u/L5CxQ/jPvijL0pZaWceBkaUHtoLkxLDEEuMd04qCGKUCCauEwI5T 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: 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()