From nobody Fri Nov 22 04:53:11 2024 X-Original-To: dev-commits-src-all@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 4XvjQw0vbjz5dLLS; Fri, 22 Nov 2024 04:53:12 +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 4XvjQv4kFVz4t0s; Fri, 22 Nov 2024 04:53:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732251191; 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=s2A1gND203Z+NtvOwRD7Bj5J6mmcBdyVteFhBk9gf8w=; b=n4moCLBM2L07ceZm/Wl5HFO+HkRyQ02KoMvQNU3vX/+prWvr1qxIbl3pEnpuN2f8zmCCx0 eLh+zneStjgLTDTVy7IgZDO2klqhb9thiGelkozA5cnU5u++avq3fgR2CAfQjpXOu+QIh9 4DEKa0DjlBpw7/oqdHEQzGI2DR6DRwTwc2q3GmiveBCPp2WzGEzq5/+xPZoij5E7X+KXbv b3wfe/MBjl62B9TG1XeYigB5dJJ+lCSTX2ZUQi6qVA6mxkRXk9J7XwwUxMVvPEnlHPwO7P Rz27X0kjMXjVomU71wpFpdVs4HtBOoNSz24zgZ//9fGFG1zG9fT6AodCG4/8AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732251191; 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=s2A1gND203Z+NtvOwRD7Bj5J6mmcBdyVteFhBk9gf8w=; b=duVEmz/utuMm3ajs/bfpy9hhKJdWEMMuS1WuF4NbaC7ZSPrHVydQ92wX4Eg2VyWShgfOIq sVLSU9deVzY2RHz6u7ID9EApAKRGBoWXDYM6LOXSrHbuYszRUXLCyyrjx25WOYArgaxfxL +qzOaP1DJEtvyJuzhsWDUM8cWY3/oZJTCslBEcnUn/deKuTMO3Nk8Xg/5thfaoyrLdUazN kECOsLhretBkwKEcgo2qS+fN8Dmo1Sgf90Fk12WRqWHvsFLypqZf/4JLDBw96LWrS+FzxV Fa6feEE/LmUDe+kO1ATZ/1SAltLzbFU4LYlNLb2Iham7D56UXaNj802YPtt5UQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1732251191; a=rsa-sha256; cv=none; b=Mfsv3n5vm2cXEpfcRYtAaMqskNvxrmWScOE5hW/GfJlWVui7AK+a6u9t6jVjUb2Zzt9hJ+ szOz6d7GVS3r2iBfUDJlh7S1CnsTKNDfh432cPoEW6BEf8exqTUH2AyQHP8yotJ3b2uv94 CoEYnQiYI85LAiL//XrGjd8QJ836ieJYGW8uRLpGEFEUkaZ78d9WbRyCVo45+PncRmOXM7 21Fe3elhngwg2KnQndqAV7cGIS70XG/qcp9e2mos6BDFfZMVshaidpK3SucHbaadoQzrhm XHVQwh+hWmLtZOVuvySqTWnTQzlDPrCjJxSgAA5FG5kbd5HNsnwgGGgE+8fZHw== 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 4XvjQv480dz19Cq; Fri, 22 Nov 2024 04:53:11 +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 4AM4rBdE034591; Fri, 22 Nov 2024 04:53:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4AM4rB2X034588; Fri, 22 Nov 2024 04:53:11 GMT (envelope-from git) Date: Fri, 22 Nov 2024 04:53:11 GMT Message-Id: <202411220453.4AM4rB2X034588@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: 7c09acc76504 - stable/14 - _utmx_op: don't recurse on chain busy List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/stable/14 X-Git-Reftype: branch X-Git-Commit: 7c09acc76504ba63305998a7abb8ece44a6b4ebe Auto-Submitted: auto-generated The branch stable/14 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=7c09acc76504ba63305998a7abb8ece44a6b4ebe commit 7c09acc76504ba63305998a7abb8ece44a6b4ebe Author: Kyle Evans AuthorDate: 2024-11-13 22:18:40 +0000 Commit: Kyle Evans CommitDate: 2024-11-22 04:52:10 +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) (cherry picked from commit f660777865fcc28e147b51362412e0286e7df78e) --- 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 2d54850da9c3..a900435e9d4e 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -2604,11 +2604,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; }