From nobody Sat Mar 08 08:13:57 2025 X-Original-To: dev-commits-src-branches@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 4Z8wsd4QtYz5qcyR; Sat, 08 Mar 2025 08:13:57 +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 4Z8wsd1lpxz3kx7; Sat, 08 Mar 2025 08:13:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1741421637; 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=Y1vefb5O9NBmhr9OnCBUzcS1KzwZwL1Cnz11wW/My8s=; b=fRK/A+Nr49ygn4Xrul3rOyj9GfBaG04jfp5X33FQpuqyKHICJswCFEVkW0EW1zHFHIdZFT +nzhlG/ddrirpA8F0rQxNVTrYuJvCI73ll0vZwbBeP0S5/mETh0CmUqldwhJB+R9bf0UFx 5vnQCgUnHPSFtMx055FJlw74WcEpsxQt2jXIc2q/+4/V/ZWMasknykXBYO9sQc3FwJLlIK 9ezvJqymXjXjgCOPp/nc7Bm8NyZCLIo0Hy/LgRxZpgPYpQRS3dgRqZcD0ZV/J0m58i4096 vSO9hrcagAAPA+T8gr+qRMOZbpEpBc+Y0VjjKtSM0a71NX9Lcx8nx+NxGy5n0w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1741421637; a=rsa-sha256; cv=none; b=izVoPMxsyBAwENBO9mXWh7V/se2+J609VoFICzn2vzGpGs3mDW7LM/La6leSrPwOLoa7rh ets9w1t47FcxrYARZETZIxDScK1wNiKWnN0jgx/ga3T30AYAo1mBBbBsKxKgV6CrO6ldL2 o2/iwfmYOsoKWOcq/H/dcHCZ94QiAs0kuCHcl/A1jOCyrBKlTTZpZz5exJWfIpWRjbf9wg ByKDjonviaXVP9buwX58qIkmCbXsAlJX5+2LfAXyzSy76VnMUhjt3iDojdU49ed9VIjG8s Dn8SuNxJmCCS8EZNt7AZiZSqCeFpZup/8TwW/2uS5gPEgPTCbLGU5eHb2j12TA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1741421637; 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=Y1vefb5O9NBmhr9OnCBUzcS1KzwZwL1Cnz11wW/My8s=; b=bjz8uzKuwpK8s31kN9FK7qOCxa1XmfNaH0r6hKyod+Tnyeem3VgZHBlKmkciNqSNOOp0sO CUmOBrBQ6blYPXBK5w9Hb9+oLRBRUm1EqCa23KtsnX69BmSWy+ydr9DfZXYOfhzH/34LdN poHCiyCpBVQdviUyTW1wjgF2j869GjGMH7gkqiv/6TwR8EaPFMC2Lo3rkPFVTupPeBQBGH S/MP+6HHgCORvuoj6DX8aqBerRnJkBrpIvGzrlyO5HYRHVoTN8KFmr/cHbIRWOiELR+FLB 4oeBHBWceyryN/qANhzG3tlskKWBfNpByPl+YOZLGcb1z1OM2X7k/5kaGCMaaA== 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 4Z8wsd15w3zPl; Sat, 08 Mar 2025 08:13:57 +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 5288DvEC097648; Sat, 8 Mar 2025 08:13:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5288Dvh4097645; Sat, 8 Mar 2025 08:13:57 GMT (envelope-from git) Date: Sat, 8 Mar 2025 08:13:57 GMT Message-Id: <202503080813.5288Dvh4097645@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: c813157a1541 - stable/14 - umtx: Add a helper for unlocked umtxq_busy() calls List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: c813157a154148d5488d841aa28aed50b3e13049 Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=c813157a154148d5488d841aa28aed50b3e13049 commit c813157a154148d5488d841aa28aed50b3e13049 Author: Mark Johnston AuthorDate: 2025-02-24 20:36:48 +0000 Commit: Mark Johnston CommitDate: 2025-03-07 22:51:48 +0000 umtx: Add a helper for unlocked umtxq_busy() calls This seems like a natural complement to umtxq_unbusy_unlocked(). No functional change intended. Reviewed by: olce, kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D49124 (cherry picked from commit b01495caac2eca73463f4a889936a19e4c1c5909) --- sys/compat/linux/linux_futex.c | 12 +++--------- sys/kern/kern_umtx.c | 34 +++++++++++++++------------------- sys/sys/umtxvar.h | 1 + 3 files changed, 19 insertions(+), 28 deletions(-) diff --git a/sys/compat/linux/linux_futex.c b/sys/compat/linux/linux_futex.c index ab2760859e16..37d0142bae8b 100644 --- a/sys/compat/linux/linux_futex.c +++ b/sys/compat/linux/linux_futex.c @@ -501,9 +501,7 @@ linux_futex_lock_pi(struct thread *td, bool try, struct linux_futex_args *args) if (error != 0) break; - umtxq_lock(&uq->uq_key); - umtxq_busy(&uq->uq_key); - umtxq_unlock(&uq->uq_key); + umtxq_busy_unlocked(&uq->uq_key); /* * Set the contested bit so that a release in user space knows @@ -642,9 +640,7 @@ linux_futex_wakeop(struct thread *td, struct linux_futex_args *args) umtx_key_release(&key); return (error); } - umtxq_lock(&key); - umtxq_busy(&key); - umtxq_unlock(&key); + umtxq_busy_unlocked(&key); error = futex_atomic_op(td, args->val3, args->uaddr2, &op_ret); umtxq_lock(&key); umtxq_unbusy(&key); @@ -701,9 +697,7 @@ linux_futex_requeue(struct thread *td, struct linux_futex_args *args) umtx_key_release(&key); return (error); } - umtxq_lock(&key); - umtxq_busy(&key); - umtxq_unlock(&key); + umtxq_busy_unlocked(&key); error = fueword32(args->uaddr, &uval); if (error != 0) error = EFAULT; diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c index 7cfe68730e7d..f326b9aa691a 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -440,9 +440,16 @@ umtxq_unbusy(struct umtx_key *key) } void -umtxq_unbusy_unlocked(struct umtx_key *key) +umtxq_busy_unlocked(struct umtx_key *key) { + umtxq_lock(key); + umtxq_busy(key); + umtxq_unlock(key); +} +void +umtxq_unbusy_unlocked(struct umtx_key *key) +{ umtxq_lock(key); umtxq_unbusy(key); umtxq_unlock(key); @@ -2371,9 +2378,7 @@ do_lock_pi(struct thread *td, struct umutex *m, uint32_t flags, if (error != 0) break; - umtxq_lock(&uq->uq_key); - umtxq_busy(&uq->uq_key); - umtxq_unlock(&uq->uq_key); + umtxq_busy_unlocked(&uq->uq_key); /* * Set the contested bit so that a release in user space @@ -2539,9 +2544,7 @@ do_lock_pp(struct thread *td, struct umutex *m, uint32_t flags, su = (priv_check(td, PRIV_SCHED_RTPRIO) == 0); for (;;) { old_inherited_pri = uq->uq_inherited_pri; - umtxq_lock(&uq->uq_key); - umtxq_busy(&uq->uq_key); - umtxq_unlock(&uq->uq_key); + umtxq_busy_unlocked(&uq->uq_key); rv = fueword32(&m->m_ceilings[0], &ceiling); if (rv == -1) { @@ -2722,9 +2725,8 @@ do_unlock_pp(struct thread *td, struct umutex *m, uint32_t flags, bool rb) TYPE_PP_ROBUST_UMUTEX : TYPE_PP_UMUTEX, GET_SHARE(flags), &key)) != 0) return (error); - umtxq_lock(&key); - umtxq_busy(&key); - umtxq_unlock(&key); + umtxq_busy_unlocked(&key); + /* * For priority protected mutex, always set unlocked state * to UMUTEX_CONTESTED, so that userland always enters kernel @@ -2787,9 +2789,7 @@ do_set_ceiling(struct thread *td, struct umutex *m, uint32_t ceiling, &uq->uq_key)) != 0) return (error); for (;;) { - umtxq_lock(&uq->uq_key); - umtxq_busy(&uq->uq_key); - umtxq_unlock(&uq->uq_key); + umtxq_busy_unlocked(&uq->uq_key); rv = fueword32(&m->m_ceilings[0], &save_ceiling); if (rv == -1) { @@ -3139,9 +3139,7 @@ do_rw_rdlock(struct thread *td, struct urwlock *rwlock, long fflag, break; /* grab monitor lock */ - umtxq_lock(&uq->uq_key); - umtxq_busy(&uq->uq_key); - umtxq_unlock(&uq->uq_key); + umtxq_busy_unlocked(&uq->uq_key); /* * re-read the state, in case it changed between the try-lock above @@ -3332,9 +3330,7 @@ do_rw_wrlock(struct thread *td, struct urwlock *rwlock, struct _umtx_time *timeo } /* grab monitor lock */ - umtxq_lock(&uq->uq_key); - umtxq_busy(&uq->uq_key); - umtxq_unlock(&uq->uq_key); + umtxq_busy_unlocked(&uq->uq_key); /* * Re-read the state, in case it changed between the diff --git a/sys/sys/umtxvar.h b/sys/sys/umtxvar.h index 647ee2a4650c..6165d37d9195 100644 --- a/sys/sys/umtxvar.h +++ b/sys/sys/umtxvar.h @@ -206,6 +206,7 @@ int umtx_key_get(const void *, int, int, struct umtx_key *); void umtx_key_release(struct umtx_key *); struct umtx_q *umtxq_alloc(void); void umtxq_busy(struct umtx_key *); +void umtxq_busy_unlocked(struct umtx_key *); int umtxq_count(struct umtx_key *); void umtxq_free(struct umtx_q *); struct umtxq_chain *umtxq_getchain(struct umtx_key *);