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: 8bit 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] = -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 --- 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 = 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 ok; + + 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; } +ok: if (!err) ww_mutex_unlock(cycle->b_mutex); if (!erra) -- 2.43.5