From mboxrd@z Thu Jan 1 00:00:00 1970 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: 8bit 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] = -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_mutex cyclic deadlocks") Fixes: e4a02ed2aaf4 ("locking/ww_mutex: Fix runtime warning in the WW mutex selftest") Signed-off-by: HÃ¥kon 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 = container_of(work, typeof(*cycle), work); struct ww_acquire_ctx ctx; int err, erra = 0; + const int max_attempts = 5; + int attempt; 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); err = ww_mutex_lock(cycle->b_mutex, &ctx); - if (err == -EDEADLK) { + if (err != -EDEADLK) + goto out; + + for (attempt = 0; attempt < max_attempts; ++attempt) { err = 0; ww_mutex_unlock(&cycle->a_mutex); ww_mutex_lock_slow(cycle->b_mutex, &ctx); erra = ww_mutex_lock(&cycle->a_mutex, &ctx); + if (erra != -EDEADLK) + break; + + erra = 0; + ww_mutex_unlock(cycle->b_mutex); + ww_mutex_lock_slow(&cycle->a_mutex, &ctx); + err = ww_mutex_lock(cycle->b_mutex, &ctx); + if (err != -EDEADLK) + break; } +out: if (!err) ww_mutex_unlock(cycle->b_mutex); if (!erra) -- 2.43.5