From nobody Fri Oct 2 06:17:45 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 0E0A633DEE9 for ; Tue, 4 Aug 2026 16:32:00 +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=1785861127; cv=none; b=HcFr4F1bH85Ic4ROdVogQ44Y2VeL+V29s2u6Crsl/87VXfmyv7SGIiQs70YNbIVCOAFQBdLR+Hxp7SpkarKNkfsVithzaNEnAZbsQHIKOQd/do8LY3nfoENoGD6kt48umrRgsrmw69yzSUefE6DtEun56Q/RW0fdBHufiKjvxu4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785861127; 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=Frm/A0T5do+GJyiCaXiAzViyYlJY1jsyL7PExfhotQ1JETDnSreSL5w7BAhyAgNQPBoeCWyj9oxB8tPh7KTpxX1HKQI70rj+gnqAE+ZP/pTnIE8NVoBJHiK4jj+glfRKLJX1NB8Bj2nuyg4Qj3+5P+bm1X3kd/Lb4yizmPyBl7o= 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=XOr33cQB; 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="XOr33cQB" 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 674FxaS21651961; Tue, 4 Aug 2026 16:31:49 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= XOr33cQBIaKpIfdsVUcesqKgwunKnSrcvsoH5q04sdk1wzjF9TR/+Bkn66o3lSqb ttT8cgGerxtN+Ka9tEFovdzUU9UiAoELJJG6ZuLtEEsUG3wMorlDJ4yqZD3VTOgS s0uIaymoRXYH2gkJOVW74UhNHtmPnaHLA90xTLPyzfmvBlKN9Mo9ZwFFS8YAKJP/ V69kfuqm9gSMgEDw8Cl/yANUddayAvTU9R3UShlBLCKbFri3X+ZtUnqtQdoc+rFI 7c6o5imaGWryEBqJ3M67WbUqcua+jwPJ/HhunBoGNafJBv0cX1zDrnDGvr4MZOCl mjWDFyLF7vLl+jFNjF3iFg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4fs8p95y89-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 04 Aug 2026 16:31:49 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.7/8.18.1.7) with ESMTP id 674GU601035084; Tue, 4 Aug 2026 16:31:45 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4fs78c9y0k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 04 Aug 2026 16:31:45 +0000 (GMT) Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.1.12) with ESMTP id 674GViIH004573; Tue, 4 Aug 2026 16:31:44 GMT Received: from lab61.no.oracle.com (lab61.no.oracle.com [10.172.144.82]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4fs78c9xxd-2; Tue, 04 Aug 2026 16:31:44 +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 v3 1/3] test-ww_mutex: Fix module cleanup Date: Tue, 4 Aug 2026 18:31:34 +0200 Message-ID: <20260804163139.3121781-2-haakon.bugge@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20260804163139.3121781-1-haakon.bugge@oracle.com> References: <20260804163139.3121781-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.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-04_03,2026-08-04_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 mlxscore=0 bulkscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2606160000 definitions=main-2608040133 X-Proofpoint-Spam-Info: AW1haW4tMjYwODA0MDEzMyBTYWx0ZWRfX1gNegd80Z2cQ k074VJurIABH4eOtX7tAc3i3tDBkZXU1xuxvXtyWNh18tNi6gWLieNqaqQ+6TMIrpTGV3tUj1Kt is/jSHIgj5R03ML6TToy0uSnmBFBsVuX5v5vxXsgyle/Jeo/3Ai8 X-Authority-Analysis: v=2.4 cv=EPU2FVZC c=1 sm=1 tr=0 ts=6a7213f5 b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=M51BFTxLslgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=EIcjfB9IiI4px24ztqRk:22 a=yPCof4ZbAAAA:8 a=1XWaLZrsAAAA:8 a=gMi_3LN3h5E03voxdxMA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=WmVTiCyuxqgg3mnwYu6p:22 X-Proofpoint-GUID: tv88IYslaCFnXyiAaTzdFxe3xn_f56Oh X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODA0MDEzMyBTYWx0ZWRfX64q/309IEJ45 SkAl4zPJjHXWd+hCA+ULXuOFbxUssWtbElwk43qoN+rJEUYSe37L2wRrzTR6MskMHrDCKqsSVYQ gjAlPgTAOp+TbtmCuqhXITHa+0XSYHigvDlG64VcUkuiPWi1sdI1w3cQgTmnDTcaQiyk07oICX7 qjsdqAbjKEFQQDC8e4KiDdBrDCjQ6zC+Yd1OLSW42gR+JDY44jBmqwAIAzP66s9qUPFfuU+3OUd g1KzDsD3iAeHloBPFHHwT7LaN8RS0Z6IAj3rS9/w3ZAUUVixX/7W1c3yyyR6F5pxA/pEHJrDWN+ h1GI6fMyIRVQiTwj7mDzGO/jWMzmo8U/kI5INNkIYFSrkl2Cj3n37PxKfkwHkDiFkMHsE90I5rT E730+crLkqVDV+vxAn86HPgIpvCS/jM7UraZ5/cVPquKLTks5BxgkpR+zPfi28dPwcFOgaPBBth 05GPmOGtcYpsJFO3Mwg== X-Proofpoint-ORIG-GUID: tv88IYslaCFnXyiAaTzdFxe3xn_f56Oh 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 Fri Oct 2 06:17:45 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 48AE63E16A8 for ; Tue, 4 Aug 2026 16:32:01 +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=1785861123; cv=none; b=H/ATzkvsq20xN4X+GvzO8FxrNbpWLYOz733gNyDvIgISn/+HCalpKsZeQDuU0dhwTqJzI4ddKql4xbhabX5MjLD5GErfL42iftnE3cJ5YBG3BqqPofCI47I3gqFe/ik5vTPfZoa5uKPWOIxzDeuaGwW4IgCoM1/BdUXFQ/EB74Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785861123; c=relaxed/simple; bh=UGTiE9PoEA6SS5x8rGxLLEUGs1EIv+4aqcJb978TU+I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TksEbylIps8N0VlSubaeFD4O9v2LbWc8QGlO54EeiQwm5AqXEizvu0ZzJ61hw97tl6eLMDN4O0+BDpYTdFeb1AhGtoUT8K9urDxh/VcPYrH//pm9Ln5oYjCenWlHhTBYwtJ1bkQyauLBOnfCliZRndiXvnyfsg+jCaNO1o81OHI= 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=QUAprVJc; 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="QUAprVJc" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 674FuA1b2490196; Tue, 4 Aug 2026 16:31:50 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= QUAprVJcsRPJUw4qzprtNy2PyKKluyU8VHxfotfvIEfh1S5k+Uyx4o7w/NNMKbNP rWoNasKFeGPeeRKChUSoEgKKlxCEFe0cnCA65jxrYBzyqJztOE/ySsf94u4pgMYx Iu46pQVPoJpz5KYBqLmq43BsIWi7DJN+BIf50MhEgyZqCdYI1Jx5fcBJimTJixiC YA+c+hoE8EQ27YDyPdyFJuIlKdTa9Y52SCg0aqYiOW6FAtJEM/hFU14uBs7MjU5d Z6IXk39af1xY/MDR66CatYOzrVuuraWwD9qoaMtF0oTB6SmFEmBAEEiBwbaAOrHq YmagMhyed+/cID4+mBXM2g== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4fs8uge0yh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 04 Aug 2026 16:31:49 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.7/8.18.1.7) with ESMTP id 674GU5hU034991; Tue, 4 Aug 2026 16:31:49 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4fs78c9y2g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 04 Aug 2026 16:31:48 +0000 (GMT) Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.1.12) with ESMTP id 674GViIJ004573; Tue, 4 Aug 2026 16:31:48 GMT Received: from lab61.no.oracle.com (lab61.no.oracle.com [10.172.144.82]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4fs78c9xxd-3; Tue, 04 Aug 2026 16:31:48 +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 v3 2/3] test-ww_mutex: Report errors from stress workers Date: Tue, 4 Aug 2026 18:31:35 +0200 Message-ID: <20260804163139.3121781-3-haakon.bugge@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20260804163139.3121781-1-haakon.bugge@oracle.com> References: <20260804163139.3121781-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.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-04_03,2026-08-04_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 mlxscore=0 bulkscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2606160000 definitions=main-2608040133 X-Proofpoint-ORIG-GUID: PUu4QOoum8bh60LgqN3gnzcSIjEyMhoV X-Authority-Analysis: v=2.4 cv=XqnK/1F9 c=1 sm=1 tr=0 ts=6a7213f5 b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=M51BFTxLslgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=BqU2WV_vvsyTyxaotp0D:22 a=yPCof4ZbAAAA:8 a=1XWaLZrsAAAA:8 a=HWq8w0C2B1yOpf0TK-AA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=WmVTiCyuxqgg3mnwYu6p:22 X-Proofpoint-Spam-Info: AW1haW4tMjYwODA0MDEzMyBTYWx0ZWRfX+pAijdFRpV+d baFJY08oCDf+giEV+GW9qea4u1rjYcKY1nBw55KYv0HtOKygn151tiNSJ/g/zd7YABqvja4hHkl y2zy0tRN1qA7q30np4hG6n/Ahaatei1KyhJW9sMezngQt0okhIZi X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODA0MDEzMyBTYWx0ZWRfX+5ZCMw87R43/ xvD47G4fTJp+w6E7n0bokD1VvJ96WWpGL2LlcmnKeogFa2Eddi48BOFbBWhO55jiSjpDlKFAsVQ UajPuz+Jjp+ZVXXYCFzC5gFkqVwsKzGmAKMYLgcnWtnwMupAUDofK0F/F35AysjCE9U/IypbmKK 8gONjjvd7zogyQihHQtxkOFBUEGSthqb133S9tMl474SlpBaDRewEnlshpL2IVHBgYTK07vjlbI 2SUAKfy27RpXXAa2PJkGnQ9dwpkYIHDdh5JRJGQkOnM9pT7e2fVhZvo00vbj6L09jjbNPn+zzUm NJXvSNSqh76lLii/Xr9kTMQLI0WwoM7JYFdQfAVYwwnf0NOPfXrFZYDuUchfnxZFBfIlJfoZgDv 81odTUYLG8snYD6ycgHEX9NykYR7VpxtQjVq2TM7zi5y3pjCS7Lb9laiGEZMZwBQBlQpVCbdlgm Nqv0nxhVZGzou0JxLkw== X-Proofpoint-GUID: PUu4QOoum8bh60LgqN3gnzcSIjEyMhoV 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 Fri Oct 2 06:17:45 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 E26CC4756D8 for ; Tue, 4 Aug 2026 16:32:24 +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=1785861147; cv=none; b=rynsFm0IWEHremZrGXbGr79O9HStFH79+224EhG7Ib3vAEbrNal0ch10s4Knvoyh5iig9MW+w5h55Nzg9HO6WkCoFMNQ/NEoDMJRT500aZk5r/SKEYggejNbHt97vpownyE/x8AMAJq0yminuKwYlW+3csYclsyi7c2MERpen5g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785861147; c=relaxed/simple; bh=jGjFinrwR4CXblVJtJ/QpM+DJAPmGubuSL6XbmWp0Co=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Vsd5Q83YWgOJkOwKU4cgWVN8Zaa+AXpv2pcWl514i+LPu2BeQrwDxL5qDOBO3E4ESMVxuv6naQY448NAzrG8HOqd/SLyYgYF2B7VVP0LRM+EJ1CRBcn83cogAHf2eBtpmhUI6Bkr2WSnKx0CETutKzEf41QbKslnI5Pt5yV0qvs= 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=oG6fvF+1; 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="oG6fvF+1" 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 674FxQWm1651614; Tue, 4 Aug 2026 16:31:53 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=c1diLzV0v3uiUX1YDF+Mjw/jfyEpr3Fk25XKCV50KGQ=; b= oG6fvF+1kjo/CxifS3Ix+GAxwYC4lmfOGFTEihXwj10cMIfhqWbuoex+PwS2nVWT CBNyZ+xtM8K0JJdtMpODheWCYDYjuqMVM8LSFHBb76ZvEcqd3uSx3W++VWrh4YPp yYFN6a0PzEH4N54XSxkVk9MyImA4plPLeb5BdHWBJeUJB9O3nmpU4cHrdND6VKNa /ZljtbKc4esPYIvDTtFPGKYVVa+lZhnxw1DTlLIKQdK67hlct8Ss4Eg1tHJN14nH JcX3kxOIweQazF92g2hQaFmydFHkVyvHgcpAXrELkcdhxHa3wk8qeNYbBzB+oNRN w6ppGn8Ccou4hN51ulE3lg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4fs8p95y8m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 04 Aug 2026 16:31:53 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.7/8.18.1.7) with ESMTP id 674GU572034977; Tue, 4 Aug 2026 16:31:52 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4fs78c9y47-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 04 Aug 2026 16:31:52 +0000 (GMT) Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.1.12) with ESMTP id 674GViIL004573; Tue, 4 Aug 2026 16:31:51 GMT Received: from lab61.no.oracle.com (lab61.no.oracle.com [10.172.144.82]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4fs78c9xxd-4; Tue, 04 Aug 2026 16:31:51 +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?= , John Stultz , Ingo Molnar Subject: [PATCH v3 3/3] test-ww_mutex: Handle transient -EDEADLK in test_cycle_work Date: Tue, 4 Aug 2026 18:31:36 +0200 Message-ID: <20260804163139.3121781-4-haakon.bugge@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20260804163139.3121781-1-haakon.bugge@oracle.com> References: <20260804163139.3121781-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.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-04_03,2026-08-04_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 mlxscore=0 bulkscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2606160000 definitions=main-2608040133 X-Proofpoint-Spam-Info: AW1haW4tMjYwODA0MDEzMyBTYWx0ZWRfXyNWIUM2FDCjF Uq/oSDKaNfXuGQ5UE9b9mAl7su7cBM3vGMPibZ28jFmN5yyBEKc5SX3Cz0q91oIyq72UPtmASHe powrx+TxA9qKWXrB3u8cWkTygs4FZx7zO0Kxhm/8kRWTYXVY+L5Q X-Authority-Analysis: v=2.4 cv=EPU2FVZC c=1 sm=1 tr=0 ts=6a7213f9 b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=M51BFTxLslgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=EIcjfB9IiI4px24ztqRk:22 a=yPCof4ZbAAAA:8 a=1XWaLZrsAAAA:8 a=Yigky_AdL1GyHuYsiloA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=WmVTiCyuxqgg3mnwYu6p:22 X-Proofpoint-GUID: sa9IFCAAY4ZjPe2dN4kyK87xplrwnYRl X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODA0MDEzMyBTYWx0ZWRfX2aXktjTjYA8D ZDiaKlPoDpOZ7cuKHHmzC1ZmYsP08iDCrAnYIOcgJ8Bc16L/Y7T87bB6dOw8oTfHPQqFiTMsJ7U 3K+vrMsAijY6v+hyuiggCGbpa2n/gSXFoTDcYv3SN7TNEX+hb40BhgIu7F2AwM6RLdQBPbhSVve /cpCQ8ZuBzHdEzmJHp8NiQa/u9Z5mq8p9JfpSB+JeXZLZgGWvqgU26blooMUIECT8ni/flWFeIw FVQqiwvDrOvU5FN7jEQzlygyV2gMK+6bfStPXl4iDkr50W63xyh1Nj8aj/zF3wgwYn0RvDLcSXm w0NP527y6wpnnanKGq8NXKzD+D62469X651egNh5rXQ0xy0fiLhz8FBOV+cdkGoT/A6mEoQKEKR EpUC5jL9AL2PLzQOrbVqnRaKaI3PB359TdSs0QBxnbDlRrpZf+dyOgxE8AGYGQEsaHvvJ50Jvw5 3blwRWHl0+DFx7XmurQ== X-Proofpoint-ORIG-GUID: sa9IFCAAY4ZjPe2dN4kyK87xplrwnYRl 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 Acked-by: John Stultz --- v2 -> v3: * Added John's a-b * Renamed the "ok" label to "out", as suggested by John 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..47e016a4f4fea 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 out; + + 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 +out: if (!err) ww_mutex_unlock(cycle->b_mutex); if (!erra) --=20 2.43.5