From nobody Mon Feb 24 21:35:09 2025 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 4Z1vCd4bxdz5nj0S; Mon, 24 Feb 2025 21:35:09 +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 4Z1vCd2vnqz3QQR; Mon, 24 Feb 2025 21:35:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1740432909; 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=vn/pR57x1Xm10R4w3ySv/jKhVJOoLz2EEwXUhlIL/SI=; b=WOZq/otZVTgMBPcpvENt6xdcQLul+CkQ1q9XFL3uXE+fD58JAYaDRm9RlJVVGuPLl4JLZY 9xCK+7iEvNOGljGfOZqGp/hbVwGvftnzEVY/A4Fefk9EjMMuMMfjrDpqOs6IXelF+dEegM hKayCSnN6ucEdpv1zL5Qm1hqih+Y9eFVFBjlpomHlUCpHkICli7thHpO1lccQER5acDMAp UbvZ4xYr9qOnp3EJCw9adEgGLtHQQR1hb8zeRSdlUvGz8JE77hARDYwgTPgQZ/D26NbZKe V6yKkXjEDznPocJpjIUSbPW0JbLr/MKkYBbMmBL8LwRBfqBLJpwv2O7txDjLDA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1740432909; a=rsa-sha256; cv=none; b=WJNqZkQRSGn37LuZBZrqsxO3MyupJlFrMDsySYAOhlrLCmOy+HtWo2YIlAVMuprP7Yc63p 37s2U6h2rXin1Nu7LIiimCp2fZus7ssrP7SWOwNEOujo4Zfm0TWVNCoXI7Y/y9qnjG3Mqc 43bJkTNoYWDSpurl+VSvfEjn/nJxrkiwO9SU8zUZOsq67qYUjDsdHCwlTioCKiyZXkAWAC mpKR/D11SCTMPe1hbcsGk6QRAcV9oUbz8xlTnWEo/yyK/5NmTVDYpNQqt0AucLO++6Fm/x faASBitN40SDRyC4rZ/pXJBJj+cjTjr2WgknIsrtn2EuwcfpoK9NkTMKM2cECQ== 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=1740432909; 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=vn/pR57x1Xm10R4w3ySv/jKhVJOoLz2EEwXUhlIL/SI=; b=a8TlOGfUbyAVOMS4WaGxaE/fgkhxRv0ADGv6sjBXtwrIXp6wmu+EgxCZ0ujGiMCiJ0k2Ee jpHaNUjtd6W13EWAed/Xg2lTtEBdm5ByL5uzULs5Ms3uEMFFyvIuQN9YVEpf+S7BdLybYd OfeSabq5QwYqTFPmmbWsFN6UKnYr4n9+gurW0ZtefEP+CCXVGs+q2t1JPTL8DX3Agl2Zzm wD4pnNJE953kOnkpHG9BWGHSoqCORlIFbfpNAhqhtlpf6wOoZpPnRP8wGP/WGNZP13PYhp 8vU0OyLb6w3TgGRYrfrAkDfC1NLZPRGrMmktFfLzLlSIDPsqFnpBud1qaHGJ+Q== 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 4Z1vCd2LPBzy2y; Mon, 24 Feb 2025 21:35:09 +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 51OLZ9hr057371; Mon, 24 Feb 2025 21:35:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 51OLZ9AS057368; Mon, 24 Feb 2025 21:35:09 GMT (envelope-from git) Date: Mon, 24 Feb 2025 21:35:09 GMT Message-Id: <202502242135.51OLZ9AS057368@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: b01495caac2e - main - umtx: Add a helper for unlocked umtxq_busy() calls 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b01495caac2eca73463f4a889936a19e4c1c5909 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=b01495caac2eca73463f4a889936a19e4c1c5909 commit b01495caac2eca73463f4a889936a19e4c1c5909 Author: Mark Johnston AuthorDate: 2025-02-24 20:36:48 +0000 Commit: Mark Johnston CommitDate: 2025-02-24 21:34:51 +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 --- 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 f9189024d629..dc6fee1f8f38 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -441,9 +441,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); @@ -2372,9 +2379,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 @@ -2540,9 +2545,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) { @@ -2727,9 +2730,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 @@ -2792,9 +2794,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) { @@ -3148,9 +3148,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 @@ -3341,9 +3339,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 *);