From nobody Thu May 19 10:31:25 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 72B811AE24EB; Thu, 19 May 2022 10:31:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4L3mNt2JFdz3D5S; Thu, 19 May 2022 10:31:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652956286; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kzCoBNE/ze9ZMhoKUdWjdau1Jfu4bL21ylzHQZYpRKs=; b=RfX6V7+kZZc7GBtS8B9BWCZDuFJot2Qg6cXcrACdT1fRi9qLO89Ev/kwJ3UpwKG2i/Z9GV 44fJ83wqZWNTzdIFPb4X9LA4q2jHILVN3Tp1slmETJih1vIAGpJm5x0Ppj81vSQoNd+9k8 2DAzszZgcygxuO0aTZOkBtkpJ8zNAPK6CAByhATAGeWxV+pZcT+mPLW8tqwpEBfBTfxGaq jaJFV0Kk9ZNI2uGZPjbC4a7NYpNe1pq79/8qZoB2kmCB6KLItsw7XG3yRbyUECKgEQ0EEq O9g+aRjwCy6pnFnUYUr9ugO7h9MW4gBzKYhGkG3KP3/NEKBAXYvoJfOpSYqQnw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1E23E1C258; Thu, 19 May 2022 10:31:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 24JAVPbf038512; Thu, 19 May 2022 10:31:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24JAVPQR038511; Thu, 19 May 2022 10:31:25 GMT (envelope-from git) Date: Thu, 19 May 2022 10:31:25 GMT Message-Id: <202205191031.24JAVPQR038511@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 11a6ecd4258b - main - Handle cas failure when the compare succeeds List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 11a6ecd4258b9108fb19420ec5db297f6d99a842 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652956286; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kzCoBNE/ze9ZMhoKUdWjdau1Jfu4bL21ylzHQZYpRKs=; b=xizMKJS8ZqqVSYNvdgGKSRU10/zaRvFy+nr94AzNkfMbiVZKhhlvTmpaBWvnPnv5Ay63Qc E1/8EXkVG4p5UZkW8axYcL7Unlqs2J+AESAMehtWQ4GuduUYjefBgQn3o4TnwDjxDUTvXy f0DOmx2YlrP3apkPmXZNkdbcGhBWVTfbPaJAbvB+CmcB6cVi3idTMYo6C3AETm8gOrtSGL PFPWyR+DxHoiIVQe147M7tLQ/lykutGIKqSQXsLOo52EXsWlSbZOk10w5Zp5mmKrA7IHfJ S/lhlfJg6fggmf5dHNJs6CM+vXk8gHCPt0msC1vEVsyoCTU90NbPvMZKLdVp0Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652956286; a=rsa-sha256; cv=none; b=saPaKCedrllhVCFpD5qr4U6ljedjZ0LmZwIPUlJl+jvpMwsJh3wasCedyk/wBon++fTzl6 uSSNrZxFCdmlVBdNzk+kW7BBcL9to3e8TngBf7nYXp9nwYFA//01zU0EMRfTYA5OWkY3kG Z9Z4yFCOLWpCFCmUEbEL37QblB/TjCOAvRnLZWtijuNxn3q7et3NWRMVwR7xlDTn17y1xW eNPBn/UyD86e9TGs3Khq/jsCGmu8wQTtQfF5HIH//p0cUlyXpiDKehJvvPBu0ELNpHA8Es sxcyt2SYPCn1O+1tmDADzKizTwpJqePjrDykyoBEZI/XTrGM5INEoIghdzFjjQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=11a6ecd4258b9108fb19420ec5db297f6d99a842 commit 11a6ecd4258b9108fb19420ec5db297f6d99a842 Author: Andrew Turner AuthorDate: 2022-05-09 14:28:56 +0000 Commit: Andrew Turner CommitDate: 2022-05-19 10:30:21 +0000 Handle cas failure when the compare succeeds When locking a priority inherit mutex we perform a compare and swap operation to try and acquire the mutex. This may fail even when the compare succeeds. Check and handle this case. PR: 263825 Reviewed by: kib, markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35150 --- sys/kern/kern_umtx.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c index 2f666bdcdc7b..d63381d76eb8 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -2262,6 +2262,17 @@ do_lock_pi(struct thread *td, struct umutex *m, uint32_t flags, break; } + /* + * Nobody owns it, but the acquire failed. This can happen + * with ll/sc atomics. + */ + if (owner == UMUTEX_UNOWNED) { + error = thread_check_susp(td, true); + if (error != 0) + break; + continue; + } + /* * Avoid overwriting a possible error from sleep due * to the pending signal with suspension check result.