From mboxrd@z Thu Jan 1 00:00:00 1970 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 AD8DF1C5F39 for ; Wed, 17 Jun 2026 12:13:56 +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=1781698438; cv=none; b=F7O2ZBinfM7+gIjWWNvLuWiuEIGIqkr2R//fXfq0iRuBARa5CdnCHnyIdB+v2iZ24iiMVWOw2Nrn/bXxrXLMklbvGWVFE0QtnSroOVupTSEnspbTUkqYo/seMWdIM8b481ag4Nds18dYi1Hxt11iI4Ve+23VOBj+BTraKxEzHrI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781698438; c=relaxed/simple; bh=KpxbI5RlM9gG8APUQuze+OckB/mWjofCNCvtgiP8Dd8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lkf8iUnRb12VoZ7odzvtVocRn2dkgHWK5pLfK5Iqe1YamoQCTyOCD5TZkiAhU0xjFOAm6dhWzV2zJKqLan9CiiD1thOFIflzhs9uyjOS+XVA7o9ZdJqrzLRWuOIT1cSwlDvBVmwRV2nOO7fPMf2XITbgtSLODYSLkVYxT5Vj0Bw= 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=fLI641DA; 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="fLI641DA" 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 65GLXmbo697782; Wed, 17 Jun 2026 12:13:43 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=e6c3fTHgaeRiORsQG7OtjLole/G7BJiAafD6J0NaDBo=; b= fLI641DA5mHtsLC7TRxvlPQeTBmNQROxnZ+FL7E08yZg6+o43Kk658mCSMuWUuIo OfVahjaz4NgX5e77sw3xGNu2mnZTy/2aw608QU9Q0M7JDwTJehqGOo1gfZ4JqBtb XvGigieBsI1fXI0/yk305MSZRFfp9/YLjN9V7x6sUNuVIffgM8Q0msOpvgu+1hWj o+2hRSnYZxvSOwUwPuELlb/4H4lLCipbqjbOEl9KIJqAZ0z93zZOk1/YHqkyPuQS itgJsV2CfudITXoOYD0eiOjaye8KWtBlf2l4xWgkopVgcc1G3SotKjnugtQEbUfN 1pELwpMtyir7e0sPRTrZWQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4euefurtfp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jun 2026 12:13:43 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.7/8.18.1.7) with ESMTP id 65HCCuUr031868; Wed, 17 Jun 2026 12:13:42 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4euduxddnw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jun 2026 12:13:42 +0000 (GMT) Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.1.12) with ESMTP id 65HCDfN6034521; Wed, 17 Jun 2026 12:13:41 GMT Received: from lab61.no.oracle.com (lab61.no.oracle.com [10.172.144.82]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4euduxddkt-2; Wed, 17 Jun 2026 12:13:41 +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 1/4] test-ww_mutex: Fix module cleanup Date: Wed, 17 Jun 2026 14:13:30 +0200 Message-ID: <20260617121335.2036954-2-haakon.bugge@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20260617121335.2036954-1-haakon.bugge@oracle.com> References: <20260617121335.2036954-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: 8bit X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-17_01,2026-06-16_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 phishscore=0 lowpriorityscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2606150000 definitions=main-2606170116 X-Authority-Analysis: v=2.4 cv=faedDUQF c=1 sm=1 tr=0 ts=6a328f77 cx=c_pps a=OOZaFjgC48PWsiFpTAqLcw==:117 a=OOZaFjgC48PWsiFpTAqLcw==:17 a=IkcTkHD0fZMA:10 a=FelO9ux0wxsA:10 a=M51BFTxLslgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=BqU2WV_vvsyTyxaotp0D:22 a=yPCof4ZbAAAA:8 a=gMi_3LN3h5E03voxdxMA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: 1MOBg79QsBC_omMfJb3qBgCOBYd2xpX6 X-Proofpoint-Spam-Info: AW1haW4tMjYwNjE3MDExNiBTYWx0ZWRfX9+r7ehuU/n3D 42mM60vKpQMNvYehvfkwa+eEhCjnY2n7mEBNa29UJStVrznrd75EUCytMiHH0thXECkmXFIB0mp R+9qNZXwPOfdBuMgUANB+WqcJdq9MTZB1GODX4YAjj6/pyGfCkmX X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjE3MDExNiBTYWx0ZWRfX9tY9NnKh/05x c/OL/3VuRozaHO9UWv71HsSR8CByOj69pfyrOcOEbdPvpHVcXnrGJkZMr9rABXkScUnPtDZauqV A5aXG/GMiYL9n3gummqBheeN3YVyjTOowIIhfruNpPE7Tj10eq0f9tpQyw5VSbS0rvPsl5/CVTV txe/bt0IiyavIvfsWvNDSzj/W4Bo2gFGOHAOeREVzqx4SYmIcXTIjnS2rkMQLM5oo2Pfveiz6UI ub38N8QRSQKGdINnoqcagbYSXsxv8DcFf1LWPB2jSyhmqiF2G0Jt39Y+EKLdkiTXqz0Y7z4lRz1 W+GRM/U0KrlY1rVXNB0oW1dFDAynXcJ6EnrO+0j9USAG0JcVo6ddb+0BswbQ5qJx0NJojMMn4EW F7G9NAlUBXaquX9CmkFInPzOACKya6Gof+q1QE/H/lL1qfmIeRDoDcmvMxC5V4y12MrQmAIQiKq uxWSh00R7lG7neHcbWA== X-Proofpoint-ORIG-GUID: 1MOBg79QsBC_omMfJb3qBgCOBYd2xpX6 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Ã¥kon Bugge --- 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..6f56a29ed6d77 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; static int __init test_ww_mutex_init(void) { - int ret; + int ret = -ENOMEM; prandom_seed_state(&rng, get_random_u64()); @@ -743,28 +743,35 @@ static int __init test_ww_mutex_init(void) return -ENOMEM; test_ww_mutex_kobj = kobject_create_and_add("test_ww_mutex", kernel_kobj); - if (!test_ww_mutex_kobj) { - destroy_workqueue(wq); - return -ENOMEM; - } + if (!test_ww_mutex_kobj) + goto kobj_err; /* Create the files associated with this kobject */ ret = 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; mutex_lock(&run_lock); ret = run_test_classes(); mutex_unlock(&run_lock); + if (!ret) + 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; } 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); } -- 2.43.5