From nobody Sat Jul 25 21:21:01 2026 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 75B62437107 for ; Mon, 13 Jul 2026 16:37:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.165.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783960653; cv=none; b=XHrNJzvEuCqyRYZ8g/TH9CNTudiLJen5W4UKphAXq6FhGVuj/oqhz9p/ih6N05ynQ86JF2U9vLMoH/V6+LhskEciIult1QfeSYYUP4tuhjeBQciCUSAfo12057TlfmGK9I0TjGl35WPI9898WMWf7fdggW+/fWGvxRlJo9AePSE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783960653; c=relaxed/simple; bh=B0qFluCe+nIvg9YwI/zuBMEY+CMOt7xNDklJ09e+O1w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mljseyeasihaIqzmOA7ywNUdZKfm+K7xKFDAHLoLuqe+WR3eOJIEC0TepISV6nPk6FBNF0+SxI0+Z4Hd3CVbra8J8skxW5lftqh+ZAp3rFFINZ8Yfk4KZKNnFbChMRnfCGqEGRgU03t674f7a3hILl9VKjB+xXyp7nADSzwmiE0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=rF4VU08F; arc=none smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="rF4VU08F" Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66DCB34g1377457; Mon, 13 Jul 2026 16:37:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2025-04-25; bh=pvGQoHM4XnE7EyDPU+oD3ECvDpZGCsg2pZOT5P8ExAU=; b= rF4VU08F03WhoP3fKk9UdpZ3Ab+w4vpEVJm+hpWWkkM1FYJRWv5v2oRIZ1c8uVtw WNSRuHHiJe5hjSpxqwXnov0cUtCJs4jXLpsWCvq48ccETnuN5E/B3wQ8ms0im6mo 0XFrQemTwy/fJzOQs2IHKrf1yWtepeV56jMoKZYplKiM85UXtUqt/jndVFEQXiQx RqbtUsIiMBBy7r31Pf/q+MIF48TrFrsEvdlyrcmVAJAz+HLkC0Nn+Bv7AGxnHd9U tChmxErIwOlQjBvMgfJbnNNEfhLN2XQJdHainwonPUamu27nTl9E5IAUgfNYu0Tr Xq9gdcA5+OIKuRFtlsSWhg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4fbed2aht7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Jul 2026 16:37:17 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.7/8.18.1.7) with ESMTP id 66DGXXsm004562; Mon, 13 Jul 2026 16:37:16 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4fbc9gfdcg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Jul 2026 16:37:16 +0000 (GMT) Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.1.12) with ESMTP id 66DGbFQI020425; Mon, 13 Jul 2026 16:37:16 GMT Received: from lab61.no.oracle.com (lab61.no.oracle.com [10.172.144.82]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 4fbc9gfdas-2; Mon, 13 Jul 2026 16:37:15 +0000 (GMT) From: =?UTF-8?q?H=C3=A5kon=20Bugge?= To: linux-kernel@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , Chris Wilson , John Stultz Cc: =?UTF-8?q?H=C3=A5kon=20Bugge?= , Ingo Molnar Subject: [PATCH v2 1/4] test-ww_mutex: Fix module cleanup Date: Mon, 13 Jul 2026 18:37:05 +0200 Message-ID: <20260713163712.638876-2-haakon.bugge@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20260713163712.638876-1-haakon.bugge@oracle.com> References: <20260713163712.638876-1-haakon.bugge@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-13_04,2026-07-10_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 suspectscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2606160000 definitions=main-2607130172 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzEzMDE3MyBTYWx0ZWRfXy7X4+SsynnZb n7tKtFmaXa2zWV0Pi/+yP0G+IzStaxOa3NYV45mhv5epbUzbbEJko1TSKlkhVmtcDD1J3QT8KYM 7VvF2TkMDJfS8+5sncIxXAYbwDKbgfZuaW2blIfXqUCb9vaal/D20j/UiUOefKhgz60k/TJu6r9 8KKgy75BAIxuvzxCeD76wUwPJVoi+1XpcMrS3sKJUOMZMoLxufSh3gH6+x3xh7KoFLOrUjQJ1XQ FhR0iWyiZZaZLBzC9BD/LOITR6frxbZrNfR9On4it9TcT+I4jLZE0keDzsZ0yC0kmyK3+MMWmKX VE9JLF+RB42mS/E1zP08SgmDPOSahk6Y6R5u+fva3BsCWl/3lJFUfoVJ6kZDVR0n6xQyej8InpV IHMxhHtdH+6ZN/7aLqeMxmjPeIB7kOI8aMdeFj2uTg/dukTpEOz+PXCx7J9mJcsD7I2P/Rb+s3V xz+T3QfYQGZemkjGUghA8cUU0TOitserksuX6nPA= X-Authority-Analysis: v=2.4 cv=GcknWwXL c=1 sm=1 tr=0 ts=6a55143d b=1 cx=c_pps a=zPCbziy225d3KhSqZt3L1A==:117 a=zPCbziy225d3KhSqZt3L1A==:17 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=M51BFTxLslgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=7Gl3-_t3PgB9XO-mQDs3:22 a=yPCof4ZbAAAA:8 a=1XWaLZrsAAAA:8 a=gMi_3LN3h5E03voxdxMA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=5yU3S35YU4bGjq-dph-N:22 a=Bho9c0fBagfJEIQBS7DQ:22 cc=ntf awl=host:12221 X-Proofpoint-GUID: YIV6yOjkhDsUIWgHyZxe8UAIaXeFmxZ4 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzEzMDE3MyBTYWx0ZWRfX01Q/SGp6gkFo m2oltFQ3GsvXV3ybRnUVg+/cC4ot+U0F47W4c6gWA1fqIYRaO+buZw86hvPZ2eCWI4mSmmPdsTz fRP8y7aKIENXN1gKSZgy2xffcWAU5t2YVNVte4skCXVWJnuPRA4N X-Proofpoint-ORIG-GUID: YIV6yOjkhDsUIWgHyZxe8UAIaXeFmxZ4 When test-ww_mutex is compiled as a module, there are two bugs. One is related to the case where the module fails to load. In that case, some or all of the allocated objects are not released. Also, if loaded OK and thereafter unloaded, the sysfs file is not removed. The latter bug gives the following splat (trimmed for better brevity): sysfs: cannot create duplicate filename '/kernel/test_ww_mutex' dump_stack_lvl+0x5d/0x90 sysfs_warn_dup.cold+0x17/0x23 sysfs_create_dir_ns+0xe2/0x100 kobject_add_internal+0xba/0x270 kobject_add+0x95/0xd0 kobject_create_and_add+0xa3/0xd0 test_ww_mutex_init+0x90/0xff0 [test_ww_mutex] do_one_initcall+0x5c/0x330 do_init_module+0x90/0x290 __do_sys_init_module+0x195/0x1d0 do_syscall_64+0xe8/0x550 entry_SYSCALL_64_after_hwframe+0x76/0x7e Fixes: 2a0c11282881 ("locking/ww_mutex: Add kselftests for ww_mutex stress") Fixes: de2c5a1523fd ("test-ww_mutex: Allow test to be run (and re-run) from= userland") Signed-off-by: H=C3=A5kon Bugge Acked-by: John Stultz --- v1 -> v2: * Keep the sysfs file if module is built-in even when the test fails. This in order to be able to run the test multiple times even in case of errors. Suggested by John Stultz --- kernel/locking/test-ww_mutex.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c index 838d631544ed2..8311ff38ab683 100644 --- a/kernel/locking/test-ww_mutex.c +++ b/kernel/locking/test-ww_mutex.c @@ -734,7 +734,7 @@ static struct kobject *test_ww_mutex_kobj; =20 static int __init test_ww_mutex_init(void) { - int ret; + int ret =3D -ENOMEM; =20 prandom_seed_state(&rng, get_random_u64()); =20 @@ -743,28 +743,35 @@ static int __init test_ww_mutex_init(void) return -ENOMEM; =20 test_ww_mutex_kobj =3D kobject_create_and_add("test_ww_mutex", kernel_kob= j); - if (!test_ww_mutex_kobj) { - destroy_workqueue(wq); - return -ENOMEM; - } + if (!test_ww_mutex_kobj) + goto kobj_err; =20 /* Create the files associated with this kobject */ ret =3D sysfs_create_group(test_ww_mutex_kobj, &attr_group); - if (ret) { - kobject_put(test_ww_mutex_kobj); - destroy_workqueue(wq); - return ret; - } + if (ret) + goto sysfs_err; =20 mutex_lock(&run_lock); ret =3D run_test_classes(); mutex_unlock(&run_lock); =20 + if (!ret || IS_BUILTIN(CONFIG_WW_MUTEX_SELFTEST)) + return 0; + + sysfs_remove_group(test_ww_mutex_kobj, &attr_group); + +sysfs_err: + kobject_put(test_ww_mutex_kobj); + +kobj_err: + destroy_workqueue(wq); + return ret; } =20 static void __exit test_ww_mutex_exit(void) { + sysfs_remove_group(test_ww_mutex_kobj, &attr_group); kobject_put(test_ww_mutex_kobj); destroy_workqueue(wq); } --=20 2.43.5 From nobody Sat Jul 25 21:21:01 2026 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (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 772FD40B363 for ; Mon, 13 Jul 2026 16:37:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.177.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783960654; cv=none; b=Uwd1lN7aUhEy1zzOoBMqxhSwT1nKiTrxB/mIlXb1rVFYvCRknmPqhnTUdeIOsTvNqIuQdpKRGWi+Jha5NtbVe5bCAJQPJGI4CAnDP6+s2jr+vA+h4tDvT+AJfaXTzmslO0VYPQqZ9H/VC07ELuyQFMK+Dv6Bth8AzCyip8Ctu48= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783960654; c=relaxed/simple; bh=UGTiE9PoEA6SS5x8rGxLLEUGs1EIv+4aqcJb978TU+I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QIZOMYyt+hutQb3gYIMCgJ/h+FQ483+r5EZ+fRSNodqfcbfXHOxYqJGohQvhmc3GNlX43DFRSLOh7WCXpCnD8pKCmqz+bL6Yjai9tdXC9Sez+CF5UdbBJlvnjvcV5jUp4EVCzWnyBFUWfwgIWmqkjZ4K4dw/ihxt9WqS7YA2BXo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=nf+yVtRW; arc=none smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="nf+yVtRW" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66DC8oik1379899; Mon, 13 Jul 2026 16:37:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2025-04-25; bh=8axs6/DwKqTZCcXgaGEvGg2rDdG/OlqeZDwlUMVsX+c=; b= nf+yVtRWEgIF00IZKz/JBI0jLQJBg68evp3sd3dJsHRR5GFgRkHSx0OiKeGyGg78 NpeklqhNCzzlL7vc4UpHvao5FGJW17ufQkoKcB8mfPIiBO2NVRZzyqkedqgjmsOR on3mi2BxRbwce0OnoKtDNN+xE8DtDY8sWh33T82dpXSjW7ZAH/SJJnb+zmby76RF pou0dpAmPPOVclLWRkpHRuzakBROr7066b6FILyuT5/viib1BT3oyx7TQHe35nPg w22HXa/Dhr0MilQt5Xz3M4Iu4KFBxi4zq9s1VPGPnrBndMM3tN7rtwLI5FYqWJco /mTkPo5lWY3FIk/TIBO23A== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4fbed82hvd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Jul 2026 16:37:19 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.7/8.18.1.7) with ESMTP id 66DGXY1C004717; Mon, 13 Jul 2026 16:37:19 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4fbc9gfde4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Jul 2026 16:37:19 +0000 (GMT) Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.1.12) with ESMTP id 66DGbFQK020425; Mon, 13 Jul 2026 16:37:18 GMT Received: from lab61.no.oracle.com (lab61.no.oracle.com [10.172.144.82]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 4fbc9gfdas-3; Mon, 13 Jul 2026 16:37:18 +0000 (GMT) From: =?UTF-8?q?H=C3=A5kon=20Bugge?= To: linux-kernel@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , Chris Wilson Cc: =?UTF-8?q?H=C3=A5kon=20Bugge?= , John Stultz , Ingo Molnar Subject: [PATCH v2 2/4] test-ww_mutex: Report errors from stress workers Date: Mon, 13 Jul 2026 18:37:06 +0200 Message-ID: <20260713163712.638876-3-haakon.bugge@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20260713163712.638876-1-haakon.bugge@oracle.com> References: <20260713163712.638876-1-haakon.bugge@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-13_04,2026-07-10_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 suspectscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2606160000 definitions=main-2607130172 X-Proofpoint-GUID: vT0cb_UcXptQdGfq6lEhQRdlkWrt9YYp X-Proofpoint-Spam-Info: AW1haW4tMjYwNzEzMDE3MyBTYWx0ZWRfX+GLvX0MhZ9bA M5EN8b1boJO3Xxwj6hYKwo1Mht4EORa90xCz0yyZwzG2kzssuAsQ9JK+sMLI1XP4U0psEskmE+2 roAuzCAlwxYpQyXiyl0mN9hEg+YBUYtvY5q+3iY2ss1EOa0ekSEY X-Authority-Analysis: v=2.4 cv=JKALdcKb c=1 sm=1 tr=0 ts=6a55143f b=1 cx=c_pps a=zPCbziy225d3KhSqZt3L1A==:117 a=zPCbziy225d3KhSqZt3L1A==:17 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=M51BFTxLslgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=o5oIOnhZENCTenyL_yNV:22 a=yPCof4ZbAAAA:8 a=1XWaLZrsAAAA:8 a=HWq8w0C2B1yOpf0TK-AA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=5yU3S35YU4bGjq-dph-N:22 a=Bho9c0fBagfJEIQBS7DQ:22 cc=ntf awl=host:12221 X-Proofpoint-ORIG-GUID: vT0cb_UcXptQdGfq6lEhQRdlkWrt9YYp X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzEzMDE3MyBTYWx0ZWRfX8K3WtvoylYv+ CoblD8ScVAXI/f/4ftzDUwZQUUKxPUfh/0ilteTlbvbwJI8wH9bmK5AEIu3omrmUbvJh2/ZuYY/ Fpig6GurZ/5kGRfUBqtzd93pmdDXDN/bo8vAsdLhYyaJlDbRdn/lYzrpRw8/j1xBE4Ajp1ZHe6V Y8TlxsqrHj35AJrCJyVhKzhp4f89+hNsDsNWf0XgPnvozEJZV/b4v+OwZ5oC8+5ZoFSNoYuLUj0 e1dWV1Nv2ASyRYrlQi6Vbbb0S5m6eoC8Or+6SZ5TA5L1avgd/2a8cMA9gobcx6nvwoFoH9fJemp Ay/NQNrDuggsAhWvtH5lmyEWBvMRe7Wh5UHKUsx7RfCTi9JCmHMHC7nrXyQx15QrvP667uBOisn e5fdnyuBA1cs6O4opZgSaJjEj2hPo52Qtc0RwDVVG6BdSkh0yOhnqTcWSZLNFdpOZ8tj6kouPFn 3EXjF1PQIzXhtcTedixYyhWbtySnEiKvtep9eOp8= If any of stress_one_work(), stress_reorder_work(), or stress_inorder_work() fails, the error is not conveyed back to the test harness function stress(). We may then see in the log: stress (stress_inorder_work) failed with -35 Beginning ww (die) mutex selftests All ww mutex selftests passed Besides being a contradiction by terms, the failure to return error from said worker functions leads to false-positive results. We fix that by adding a *result* variable to *struct stress*, update it in said worker functions, and finally, in stress(), scan the *stress_array* and report the first error if any. Fixes: 2a0c11282881 ("locking/ww_mutex: Add kselftests for ww_mutex stress") Signed-off-by: H=C3=A5kon Bugge Acked-by: John Stultz --- v1 -> v2: * Added John's a-b --- kernel/locking/test-ww_mutex.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c index 8311ff38ab683..5ed91f2cf30d9 100644 --- a/kernel/locking/test-ww_mutex.c +++ b/kernel/locking/test-ww_mutex.c @@ -392,6 +392,7 @@ struct stress { struct ww_class *class; unsigned long timeout; int nlocks; + int result; }; =20 struct rnd_state rng; @@ -440,6 +441,9 @@ static void stress_inorder_work(struct work_struct *wor= k) struct ww_mutex *locks =3D stress->locks; struct ww_acquire_ctx ctx; int *order; + int err; + + stress->result =3D -ENOMEM; =20 order =3D get_random_order(nlocks); if (!order) @@ -447,7 +451,7 @@ static void stress_inorder_work(struct work_struct *wor= k) =20 do { int contended =3D -1; - int n, err; + int n; =20 ww_acquire_init(&ctx, stress->class); retry: @@ -485,6 +489,7 @@ static void stress_inorder_work(struct work_struct *wor= k) } while (!time_after(jiffies, stress->timeout)); =20 kfree(order); + stress->result =3D err; } =20 struct reorder_lock { @@ -501,6 +506,8 @@ static void stress_reorder_work(struct work_struct *wor= k) int *order; int n, err; =20 + stress->result =3D -ENOMEM; + order =3D get_random_order(stress->nlocks); if (!order) return; @@ -545,6 +552,8 @@ static void stress_reorder_work(struct work_struct *wor= k) ww_acquire_fini(&ctx); } while (!time_after(jiffies, stress->timeout)); =20 + stress->result =3D err; + out: list_for_each_entry_safe(ll, ln, &locks, link) kfree(ll); @@ -569,6 +578,8 @@ static void stress_one_work(struct work_struct *work) break; } } while (!time_after(jiffies, stress->timeout)); + + stress->result =3D err; } =20 #define STRESS_INORDER BIT(0) @@ -581,6 +592,7 @@ static int stress(struct ww_class *class, int nlocks, i= nt nthreads, unsigned int struct ww_mutex *locks; struct stress *stress_array; int n, count; + int res =3D 0; =20 locks =3D kmalloc_objs(*locks, nlocks); if (!locks) @@ -635,10 +647,15 @@ static int stress(struct ww_class *class, int nlocks,= int nthreads, unsigned int =20 for (n =3D 0; n < nlocks; n++) ww_mutex_destroy(&locks[n]); + + /* Report the first error */ + for (n =3D 0; !res && n < count; n++) + res =3D stress_array[n].result; + kfree(stress_array); kfree(locks); =20 - return 0; + return res; } =20 static int run_tests(struct ww_class *class) --=20 2.43.5 From nobody Sat Jul 25 21:21:01 2026 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (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 891F830ACF1 for ; Mon, 13 Jul 2026 16:37:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.177.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783960665; cv=none; b=qxRncf5PUKUp1EVduJvX/wIPlsR1l3aJWSI0gxyAGpeY8yad5VUJnRoNac6+zRS05TDRjTaIhVdUOXIlBR+WKodk+VkzEJOsAe5CKtUT8XZQ6TGnJDH73Hxvx+hTt3vGbO/fFaU/UqYIuPmHuY65PwcGVxGBNABkFHSq/Se6u5M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783960665; c=relaxed/simple; bh=H2YYxAwc71aROG8gkjSYL/hMAgeOr+foP0hrSBmJIcc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=L0uhIwCxYhvc+66PDXv1oUC5pQQ2mdF1B9dJCCIXgh/WI8LtyNrUNJw+ngNziukLhFgoaLsWLqtAsFA66kpoI12HM303wjPRwDtj2RcUoZk4cfI0xYEEs069OMXNFMhmLo/Mt6l1C5WYQYI5J2Rw46negGglx6DrPKYvlUCZvCs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=OkTK+yXF; arc=none smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="OkTK+yXF" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66DC94ME1380177; Mon, 13 Jul 2026 16:37:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2025-04-25; bh=qslf8Ne5YhTmwpa0mQhZxEVRQrCSy81kmsYBMNVYiFM=; b= OkTK+yXFKu+dZY0whPxGg5LkkZZdK+bEOrSRUUg8OnABu/6UHU/0mb5EmwNZkDUk q7vcjsvCHZSIx0LTWNOo0deU64ZCCmGF3w81RoWsjsfMmu74V88QMPY3tb2UsraR TflbCtEgu5d+CAw2va2lEJb8p+c2aFCXLVeOZDax4Nf+++zN550AtZiFV1dB1FQN 0RDSwTwuBQERzgsiS9e+SZc+fFGjmdfDicBPhhVZJEHSlkDP/FJMXh76cmHAvY6j b7qURFVhxlTF3uXbYoPxZSvhAW+R2ChBuQ0GhnQaKRqKug4q68+Ub3HLzGEAvZoG Z0oBsOd1cpIiPmHkn/yLrQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4fbed82hvn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Jul 2026 16:37:22 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.7/8.18.1.7) with ESMTP id 66DGXX6S004644; Mon, 13 Jul 2026 16:37:21 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4fbc9gfdfs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Jul 2026 16:37:21 +0000 (GMT) Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.1.12) with ESMTP id 66DGbFQM020425; Mon, 13 Jul 2026 16:37:21 GMT Received: from lab61.no.oracle.com (lab61.no.oracle.com [10.172.144.82]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 4fbc9gfdas-4; Mon, 13 Jul 2026 16:37:21 +0000 (GMT) From: =?UTF-8?q?H=C3=A5kon=20Bugge?= To: linux-kernel@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , Chris Wilson , Guenter Roeck Cc: =?UTF-8?q?H=C3=A5kon=20Bugge?= , Ingo Molnar Subject: [PATCH v2 3/4] test-ww_mutex: Handle transient -EDEADLK in test_cycle_work Date: Mon, 13 Jul 2026 18:37:07 +0200 Message-ID: <20260713163712.638876-4-haakon.bugge@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20260713163712.638876-1-haakon.bugge@oracle.com> References: <20260713163712.638876-1-haakon.bugge@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-13_04,2026-07-10_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 suspectscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2606160000 definitions=main-2607130172 X-Proofpoint-GUID: CJ16CzFjULI-lJCilEE3ZSQN2Bptf2GD X-Proofpoint-Spam-Info: AW1haW4tMjYwNzEzMDE3MyBTYWx0ZWRfX4fl/V+oRgECF lSd/1iyJusgJdqa8gkqFhbXd6zikEfDTrtPZJmVspV6xlQijSfmdDBKaPQMx/ufshy7e7PhqErt oF+HSx2H7RInxebBhvsMROioe+/U1MDxBnhooD3GXEMpuQG01QmM X-Authority-Analysis: v=2.4 cv=JKALdcKb c=1 sm=1 tr=0 ts=6a551442 b=1 cx=c_pps a=zPCbziy225d3KhSqZt3L1A==:117 a=zPCbziy225d3KhSqZt3L1A==:17 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=M51BFTxLslgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=o5oIOnhZENCTenyL_yNV:22 a=yPCof4ZbAAAA:8 a=Yigky_AdL1GyHuYsiloA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=5yU3S35YU4bGjq-dph-N:22 a=Bho9c0fBagfJEIQBS7DQ:22 cc=ntf awl=host:12221 X-Proofpoint-ORIG-GUID: CJ16CzFjULI-lJCilEE3ZSQN2Bptf2GD X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzEzMDE3MyBTYWx0ZWRfXxCR5deHWWqDx gkdUDeUAlJ3WOr8kE+XrLT3krwAyAH5OGC0VDqvmLnvsa+RFYXZPYumsI6h5sRm+rKXsb8Hd0rT FwXT+nqje8Va0mcGdc2aJUkjkJUnS5tNwF6aq11P4C/8QET7xOtqDDtxIhcqtNHP+5voUm9oaKo BXp81VNZ79VN8Ps/isO3aWUPpgqZipdHxcuwvnGq4FWud2SO3CAeFInU+QNa9STqHg30SY88oFt ooKapav9YZGc11Hf46lbOwBFMLJLyN0atOJ9htsIeGtnrd4mfc3wwgGauUj5AJ8YotUtWZnAEi2 YW7ZAw0CgDz/BcQJfEVJfWP0U3eb5ZdTclLcL8v7ww+LqhPWhsO9MsuBUrr8Uc11IHydldq6zd3 TbGRSMPdOSZccg6oWITbJPAU0rZASyosAEYN+WP3vilJ9/CopV7wMdRhJsjdzZcBXXf4KPoQFFt aUVu4Td/v7Az1joQY8prpBHslkOX7ablFd+RAPcE= There is a timing issue in test_cycle_work(), in the sense that acquiring *a_mutex* after deadlock has been detected on the *b_mutex*, may not succeed immediately. This may lead to false negatives, which shows up in the log as: cyclic deadlock not resolved, ret[77/93] =3D -35 We re-factor the inner part test_cycle_work(), where we loop a few times attempting to acquire the mutexes in BAAB order. If the first A succeeds or the last B succeeds, we break out of the loop. Fixes: d1b42b800e5d ("locking/ww_mutex: Add kselftests for resolving ww_mut= ex cyclic deadlocks") Fixes: e4a02ed2aaf4 ("locking/ww_mutex: Fix runtime warning in the WW mutex= selftest") Signed-off-by: H=C3=A5kon Bugge --- v1 -> v2: * Removed the end-less lock acquisition attempts, as that strategy did not obey the big-rules of the WW mutexes. Instead, re-factor the test, and loop a handful times. --- kernel/locking/test-ww_mutex.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c index 5ed91f2cf30d9..190b8ac5c5520 100644 --- a/kernel/locking/test-ww_mutex.c +++ b/kernel/locking/test-ww_mutex.c @@ -294,6 +294,8 @@ static void test_cycle_work(struct work_struct *work) struct test_cycle *cycle =3D container_of(work, typeof(*cycle), work); struct ww_acquire_ctx ctx; int err, erra =3D 0; + const int max_attempts =3D 5; + int attempt; =20 ww_acquire_init_noinject(&ctx, cycle->class); ww_mutex_lock(&cycle->a_mutex, &ctx); @@ -302,13 +304,26 @@ static void test_cycle_work(struct work_struct *work) wait_for_completion(&cycle->b_signal); =20 err =3D ww_mutex_lock(cycle->b_mutex, &ctx); - if (err =3D=3D -EDEADLK) { + if (err !=3D -EDEADLK) + goto ok; + + for (attempt =3D 0; attempt < max_attempts; ++attempt) { err =3D 0; ww_mutex_unlock(&cycle->a_mutex); ww_mutex_lock_slow(cycle->b_mutex, &ctx); erra =3D ww_mutex_lock(&cycle->a_mutex, &ctx); + if (erra !=3D -EDEADLK) + break; + + erra =3D 0; + ww_mutex_unlock(cycle->b_mutex); + ww_mutex_lock_slow(&cycle->a_mutex, &ctx); + err =3D ww_mutex_lock(cycle->b_mutex, &ctx); + if (err !=3D -EDEADLK) + break; } =20 +ok: if (!err) ww_mutex_unlock(cycle->b_mutex); if (!erra) --=20 2.43.5 From nobody Sat Jul 25 21:21:01 2026 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 7EC8643C047 for ; Mon, 13 Jul 2026 16:37:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.165.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783960658; cv=none; b=GA8MREmRsanJS3TgPDYbPz4bQcyaM/DwqkHTBUtU99W1NRDm8kgHV6aRPk5bWCUh88ytrTARINxjTWgyL5gH3nG9LTQoBJvstB3y6YkW7Q4CtclYV8HApPPtmGbHfRCv2lX+E1cSrd6YM6ndtp3As2q3ipRDLLYDu8KkpN7J5s8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783960658; c=relaxed/simple; bh=v4IgEPdGPqOrGJq+/TaWpyCT4EpVpuoBwGTOn770zMo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lHs3PfXVjoZyJ5FWzo4YDRbc8LE3wZrgJqFOyZPyRjxF/vaU3GM142JtX7Pok7LpYkp6SFJ7Mbx02BdwZIPPFLY+vaO7EQLRlaM9P1n++dfXFTlYexzW3biEBoxjQiA/AEmQdUybJ8X4rjrRsmNOB2jt21GM8UrzaVDh9+h4FdA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=DwoT372g; arc=none smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="DwoT372g" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66DCBwaW1396297; Mon, 13 Jul 2026 16:37:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2025-04-25; bh=/jpE0dd15855ovfNfjvRg/RHhGfqJgMvKJl89LxcNGs=; b= DwoT372gIZS9jJHwQ/UaRgOJ+zy3/tybOB3Ix/fkChNRYKij5vJsXtj+bV+nGuFY G6zVU4u1oxIAJLnxrGsiTX4/T/J7go16bm05arNosIriXjDH6+J5VcSCQScpRzvk J1E89190DR7bJHRsFSpSrHlQlGBCtCwguKxDCa3bExhabUNCckQnegPZR5FtPWkG 2yFqRkaI032SvYFHB0dErmUKq3n66yK1nr/sd/mjiG/H6q4H5qriGYPYWZdQAQx3 l3P1kNWzDJE5GaEjZ/+AlNKMGJY8HJ4ds+lmkln3ldIoShyVxLLu58vq3KALZh8f 3yG/a5Z8EeDwU9MRvvHZgw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4fbef0tha9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Jul 2026 16:37:25 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.7/8.18.1.7) with ESMTP id 66DGXYo4004663; Mon, 13 Jul 2026 16:37:24 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4fbc9gfdhd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Jul 2026 16:37:24 +0000 (GMT) Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.1.12) with ESMTP id 66DGbFQO020425; Mon, 13 Jul 2026 16:37:23 GMT Received: from lab61.no.oracle.com (lab61.no.oracle.com [10.172.144.82]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 4fbc9gfdas-5; Mon, 13 Jul 2026 16:37:23 +0000 (GMT) From: =?UTF-8?q?H=C3=A5kon=20Bugge?= To: linux-kernel@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , John Stultz Cc: =?UTF-8?q?H=C3=A5kon=20Bugge?= , Ingo Molnar Subject: [PATCH v2 4/4] test-ww_mutex: Retry lock acquisition after timeout if deadlocked Date: Mon, 13 Jul 2026 18:37:08 +0200 Message-ID: <20260713163712.638876-5-haakon.bugge@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20260713163712.638876-1-haakon.bugge@oracle.com> References: <20260713163712.638876-1-haakon.bugge@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-13_04,2026-07-10_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 suspectscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2606160000 definitions=main-2607130172 X-Proofpoint-GUID: Dta1mq8BgmJxMbyHtI54ZlYjmUOkjN8m X-Proofpoint-Spam-Info: AW1haW4tMjYwNzEzMDE3MyBTYWx0ZWRfX2/zlo8vPMlTX M11J+nSWdY9G5tzeKpbDZB9kbHa0FR7+BDyg3SZeoM6ddO8OT9u/Rl3GRBqiS5OO0511JL24/3R etuD8xk0mngc+oknyQxTgPWJZtdP7/DAKS4+lABxI72WSxYozuhi X-Authority-Analysis: v=2.4 cv=KJZqylFo c=1 sm=1 tr=0 ts=6a551445 b=1 cx=c_pps a=zPCbziy225d3KhSqZt3L1A==:117 a=zPCbziy225d3KhSqZt3L1A==:17 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=M51BFTxLslgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=EIcjfB9IiI4px24ztqRk:22 a=yPCof4ZbAAAA:8 a=EReQOji3x1dJbK8aeRgA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=5yU3S35YU4bGjq-dph-N:22 a=Bho9c0fBagfJEIQBS7DQ:22 cc=ntf awl=host:12221 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzEzMDE3MyBTYWx0ZWRfX60QuJBXz0Mf8 Sw2qVYBC6hz5CYfPAepbKQcN4ugTyTf69UyKfUMvvy6uvvQqJuIi3yapiO+Rw/uI7+SwRE/mwhi 8acAxcZCoEOkmcAkjV/O4xVsRrmTW6xyrkwrHaF+OZmVBteuc8kYw5tOzxsCk6SthG9pv/5p+my 7VhYsznzVDkDeAG1sqJndqfHtaIMfmhbSuEarwWqs9NE+DZTn1HEt7QY/MmfHvQWI3cPqrcN87Q vhDAGUllcv0efcJKrrBq6Q/YpKIKJGUCcyfLsrELNUrqU6FYmc2VXl+2YAkTXqevqXoNzIxCPbA /KKWHFNVwusF2+Vr0yUUVmEtCSTWJP3EbaDnRnsgEurfhRkSG5iJ1L/uG9LqXVya05U5Zc64wns j9IBDRsszF213GQr2746XeZ2pzGHmCmWSrk1l7NIJRihUmo8XobaTUt8x+OjXQqhfzKL1dD/d8C A/v/9aueIzQfW8rzmeszcjvL4pPHVz83kKHPlg3A= X-Proofpoint-ORIG-GUID: Dta1mq8BgmJxMbyHtI54ZlYjmUOkjN8m stress_inorder_work() terminates when its timeout expires. If the final lock acquisition attempt returns -EDEADLK at that point, the test may report a false failure. With a high number of threads and few locks, there is a very high probability that a thread will be subject to lock contention. That implies, when the loop times out, we will most probably have been exposed to a -EDEADLK return. Therefore, we retry a finite number of times after timeout before reporting failure. We retry up to 10,000 loops after timeout. This value was determined empirically: 10 and 100 retries were insufficient on the test systems, while 10,000 provided stable results and avoided false negatives. Without this commit, we may see in the log: Beginning ww (wound) mutex selftests stress (stress_inorder_work) failed with -35 Fixes: cfa92b6d5207 ("locking/ww_mutex/test: Make sure we bail out instead = of livelock") Signed-off-by: H=C3=A5kon Bugge --- v1 -> v2: * Reworded commit message --- kernel/locking/test-ww_mutex.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c index 190b8ac5c5520..e97f7d94ca5ef 100644 --- a/kernel/locking/test-ww_mutex.c +++ b/kernel/locking/test-ww_mutex.c @@ -457,6 +457,7 @@ static void stress_inorder_work(struct work_struct *wor= k) struct ww_acquire_ctx ctx; int *order; int err; + int attempts_after_tmout =3D 10000; =20 stress->result =3D -ENOMEM; =20 @@ -489,7 +490,7 @@ static void stress_inorder_work(struct work_struct *wor= k) ww_mutex_unlock(&locks[order[n]]); =20 if (err =3D=3D -EDEADLK) { - if (!time_after(jiffies, stress->timeout)) { + if ((!time_after(jiffies, stress->timeout)) || attempts_after_tmout--) { ww_mutex_lock_slow(&locks[order[contended]], &ctx); goto retry; } --=20 2.43.5