From nobody Wed Nov 13 22:18:47 2024 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 4Xpd3W3ZFtz5cfBw; Wed, 13 Nov 2024 22:18:47 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Xpd3W2vLbz4WwQ; Wed, 13 Nov 2024 22:18:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731536327; 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=w7kfai3hqnbQsbQOFVTzBedxdOSFjSnPaG0cYzzIDOI=; b=HWCcGPj91KyAVAAG9zZ70W3oHY8AJNZY2xN1x00F4mX0W8jxZ5qYGlPSyjgwAY1YZLEbEB NN2PLKTZOPXpa4F8ebEP3RjLnFN7BNWsZ0Ms92cn3IvU1sYXEYhVH+ItDfzylTVyNqn1ic vUio+dcLHP4Y4jdViRTj3I4sinIhMiqIPyLwdzDPg9HfbGaqCXXqH2fGGpcv1rFWvQNhdU sajQxN3Q+N2VkSwIJELaIIY9DVO0QrTW740/mR2Wnt4ztNIUZqu/SD1o7dpkUVxUGZ/d/d FP5yJiuW7Bk2E8djQOBFRccE/pBAX0bMafmnDJKzfYKD7+LysCeKI+zIoR1X8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731536327; 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=w7kfai3hqnbQsbQOFVTzBedxdOSFjSnPaG0cYzzIDOI=; b=XytzXSy/3ZhW8F45jpPmevPBEl/8gp8hlltgAtrFLVvDEs8ns/srukTRgf+3XxdykXx9xy m+RtsMWSKCQTwPgcjKhbudkDRped6+3elBqYWukbaTU8tBZd8aNR8K4IKhsyiG8MmIjKfc OzllMeRnZgNB2gDTbfZBenWnv4yJmzTeRAe9RQrXZnHPo/CqCpGSLUnqDYkMBcW6EeGdLt jM0b03ZtIn9n71YvHBi1SUXDDZewVPPfBRAJxEBrj6DT3nU2YnM7Ma5ll+WgN7rBa3gP7I 3naCDy4Vjht3RSVylf/E7qevxe2ndr74niGMJEf02zQXlvkAJwI2Jx23cOsGHw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1731536327; a=rsa-sha256; cv=none; b=ou4M11jd7LaCBI3FvYnQW0Qi5CN7pFpPQncGIFQwfq1sBqkxX4JtzJagFc5OWYsjCkD5r1 0/XhJExRh/t+d00IFC7c9F6sMjzyHqfka8yorTanwlVUTDcBsrbpkiUuBz6eQKzQ+p6UQq RzhoS0tGFc6dF/AXVZwhPaaPZdNNme5gGPnwCEkqKfbg3XQH+yliKSMZUvGp2Yk+kSe02j cbWbeT+6e7/9ZPvofQQ8gd0Q1rDSGX3RjWh67gaV+KLf74TJ6qxeZZ+IQSKkinVxfab2d0 Av9QGCSLI31ebvFvatsQZDYudy/87LbOdL744mv9tI+hAA/fdtEz6VINJKsylw== 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 4Xpd3W2N2pz1C5Q; Wed, 13 Nov 2024 22:18:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4ADMIlu2048760; Wed, 13 Nov 2024 22:18:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4ADMIlEf048757; Wed, 13 Nov 2024 22:18:47 GMT (envelope-from git) Date: Wed, 13 Nov 2024 22:18:47 GMT Message-Id: <202411132218.4ADMIlEf048757@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: f660777865fc - main - _utmx_op: don't recurse on chain busy 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f660777865fcc28e147b51362412e0286e7df78e Auto-Submitted: auto-generated The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=f660777865fcc28e147b51362412e0286e7df78e commit f660777865fcc28e147b51362412e0286e7df78e Author: Kyle Evans AuthorDate: 2024-11-13 22:18:40 +0000 Commit: Kyle Evans CommitDate: 2024-11-13 22:18:40 +0000 _utmx_op: don't recurse on chain busy In handling a PP mutex, we'll busy it as soon as we enter the loop and unbusy it either prior to sleeping or at exit time. In this particular case, if we fail to transition the mutex from OWNERDEAD -> owned because of casueword(9) failure and the suspend check fails, we'll start over and attempt to busy an already-busied chain and irrecoverably lock up both this thread and anything else that tries to busy the chain. Unbusy the chain prior to restarting because I couldn't decide if that was a better or worse idea than just keeping track of whether we dirtied it in do_lock_pp() and avoiding re-dirty. This is marginally easier to reason about as it returns us to expected state on entry to the loop. While we're here, simplify the code a bit as `error` will be clobbered right after the branch anyways. Reviewed by: kib, olce (both earlier version) Differential Revision: https://reviews.freebsd.org/D47493 --- sys/kern/kern_umtx.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c index 705571930d7b..b71fa9a6de24 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -2605,11 +2605,9 @@ do_lock_pp(struct thread *td, struct umutex *m, uint32_t flags, */ if (error == 0) { error = thread_check_susp(td, false); - if (error == 0) { - if (try != 0) - error = EBUSY; - else - continue; + if (error == 0 && try == 0) { + umtxq_unbusy_unlocked(&uq->uq_key); + continue; } error = 0; }