From nobody Mon Jul 27 16:17:52 2026 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 4h83fS66djz6nBqP for ; Mon, 27 Jul 2026 16:17:52 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4h83fS5SvGz435d for ; Mon, 27 Jul 2026 16:17:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785169072; 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=6o5tBhIJlrHI6gInKogwF0z+VJfxu/x5kcsiv5CAhLw=; b=qn5EtraXW6uqkdEb4Fw/BRjDvyp1FMVPyUC8tJEEUWz3FRrR/UihMwMLBW+hfllzaTrtOi oH4OfuJb/kh6mQh1+nNRyJceu6SGJiKosRZt35tEvSfNb248IVkjtz+dsakM+bbi3MQ+yN 8HybsrorZThE5hN58QiAQ1Qy0xctzHASlyn8wXPLI+K4BTVjxAnLnkjjTFVjkYO+H34gL7 /uB0f8cyC5ZBUA071+/o9xDhs1AxXeuan4aVmQ2SbvLsqcGX5w4JIArfp6FT6jwuFKkymt iBbqwn7k5Q0yHl7345/jpVJ4BiN0NXP/69pOHqe8ruUAUoFt+4NYX7xe+q/zKg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1785169072; a=rsa-sha256; cv=none; b=WfFyyQh0KL73RwD3aX2Y0OscbHs2+f5bmaWEQpXOgn4IqPeagqqcAiBIMUYmh3qtUvIh5x JoTtoWdH9tvMn91aPc71GT7kuJxK3kAYVT4C3nWEvPzOhMpqKhEYZwejF9x5PP/gnIufh6 a6+ZlhEDa6Y2E2ovhnOVWxKpm5DXDfDVo7c4za5A0dh0oOzC48tlETHCYeP8GvEaNMXP+I l0FYvxGR9QHwju559WnWnbAOiHOqO9Nq9uL5tNeibXuvuS5b0p/33tv/1NRXvtE/fB/2+1 Mnhv+v8mAEf7ZhgjFAI1/jqk4xXFlCdWaXIbYRN92INmMlV92XhVheuny2i95Q== 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=1785169072; 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=6o5tBhIJlrHI6gInKogwF0z+VJfxu/x5kcsiv5CAhLw=; b=IAINeI5c3G2FTYcnTU8MYHXfLH+vH+nopWElvJbJ5ga3lwsM1/tpGsuiKLksex6GLMVg0I h+B+f75H61QYSJ57rthBLlicHpComJxHxVn5XNh3vXC8swh/PogRam5MFMWPbsb5zuyoiJ 1EfcEJNoNPF+rarArgsfRZWgRR5HMTPyPu2nxVplaZNAu70Ue7z3OdNpD+3TbjpHzmdsGi eyju8Y/nWVINf8p71TvEhfj5KrJKZbrh9gGd6iyjXt7rTfHP1Earki0cyz4YqhyEkSAzN/ BwyhZ0ps++JOl4M19U1yNZ+ByT7okvXYsxnLFe+utwPcM6L5ExYmnzIqa2iA0w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4h83fS4HsNz1Ff3 for ; Mon, 27 Jul 2026 16:17:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1be71 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 27 Jul 2026 16:17:52 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: d738f66fab92 - main - umtx_op(2): add the CVWAIT_UMTX_TIME flag for the UMTX_OP_CV_WAIT_UC request 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 List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d738f66fab9208ee3bccea5fed293d8ce3ee5ca3 Auto-Submitted: auto-generated Date: Mon, 27 Jul 2026 16:17:52 +0000 Message-Id: <6a6784b0.1be71.61251996@gitrepo.freebsd.org> The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=d738f66fab9208ee3bccea5fed293d8ce3ee5ca3 commit d738f66fab9208ee3bccea5fed293d8ce3ee5ca3 Author: Konstantin Belousov AuthorDate: 2026-07-25 22:30:37 +0000 Commit: Konstantin Belousov CommitDate: 2026-07-27 16:17:28 +0000 umtx_op(2): add the CVWAIT_UMTX_TIME flag for the UMTX_OP_CV_WAIT_UC request Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D58463 --- sys/kern/kern_umtx.c | 90 ++++++++++++++++++++++++++++++++-------------------- sys/sys/umtx.h | 1 + 2 files changed, 56 insertions(+), 35 deletions(-) diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c index d9798fb2adb6..ab6e578ab380 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -2934,11 +2934,10 @@ do_unlock_umutex(struct thread *td, struct umutex *m, bool rb) static int do_cv_wait(struct thread *td, struct ucond *cv, struct umutex *m, - struct timespec *timeout, u_long wflags) + struct umtx_abs_timeout *timo, u_long wflags) { - struct umtx_abs_timeout timo; struct umtx_q *uq; - uint32_t flags, clockid, hasw; + uint32_t flags, hasw; int error; uq = td->td_umtxq; @@ -2949,23 +2948,6 @@ do_cv_wait(struct thread *td, struct ucond *cv, struct umutex *m, if (error != 0) return (error); - if ((wflags & CVWAIT_CLOCKID) != 0) { - error = fueword32(&cv->c_clockid, &clockid); - if (error == -1) { - umtx_key_release(&uq->uq_key); - return (EFAULT); - } - if ((clockid < CLOCK_REALTIME || - clockid >= CLOCK_THREAD_CPUTIME_ID) && - clockid != CLOCK_TAI) { - /* hmm, only HW clock id will work. */ - umtx_key_release(&uq->uq_key); - return (EINVAL); - } - } else { - clockid = CLOCK_REALTIME; - } - umtxq_lock(&uq->uq_key); umtxq_busy(&uq->uq_key); umtxq_insert(uq); @@ -2990,15 +2972,9 @@ do_cv_wait(struct thread *td, struct ucond *cv, struct umutex *m, error = do_unlock_umutex(td, m, false); - if (timeout != NULL) - umtx_abs_timeout_init(&timo, clockid, - (wflags & CVWAIT_ABSTIME) != 0, timeout); - umtxq_lock(&uq->uq_key); - if (error == 0) { - error = umtxq_sleep(uq, "ucond", timeout == NULL ? - NULL : &timo); - } + if (error == 0) + error = umtxq_sleep(uq, "ucond", timo); if ((uq->uq_flags & UQF_UMTXQ) == 0) error = 0; @@ -4138,19 +4114,63 @@ static int __umtx_op_cv_wait(struct thread *td, struct _umtx_op_args *uap, const struct umtx_copyops *ops) { + struct umtx_abs_timeout *timop, timo; struct timespec *ts, timeout; + struct _umtx_time umtime; + struct ucond *cv; + u_long wflags; + uint32_t clockid; int error; - /* Allow a null timespec (wait forever). */ - if (uap->uaddr2 == NULL) - ts = NULL; - else { - error = ops->copyin_timeout(uap->uaddr2, &timeout); + cv = uap->obj; + wflags = uap->val; + if ((wflags & ~(CVWAIT_CHECK_UNPARKING | CVWAIT_ABSTIME | + CVWAIT_CLOCKID | CVWAIT_UMTX_TIME)) != 0 || + ((wflags & (CVWAIT_ABSTIME | CVWAIT_CLOCKID)) != 0 && + (wflags & CVWAIT_UMTX_TIME) != 0)) + return (EINVAL); + + if ((wflags & CVWAIT_UMTX_TIME) == 0) { + /* Allow a null timespec (wait forever). */ + if (uap->uaddr2 == NULL) { + ts = NULL; + } else { + error = ops->copyin_timeout(uap->uaddr2, &timeout); + if (error != 0) + return (error); + ts = &timeout; + } + if ((wflags & CVWAIT_CLOCKID) != 0) { + error = fueword32(&cv->c_clockid, &clockid); + if (error == -1) + return (EFAULT); + } else { + clockid = CLOCK_REALTIME; + } + if (ts != NULL) { + umtx_abs_timeout_init(&timo, clockid, + (wflags & CVWAIT_ABSTIME) != 0, ts); + timop = &timo; + } else { + timop = NULL; + } + } else { + if (uap->uaddr2 == NULL) + return (EINVAL); + error = ops->copyin_umtx_time(uap->uaddr2, ops->umtx_time_sz, + &umtime); if (error != 0) return (error); - ts = &timeout; + timop = &timo; + umtx_abs_timeout_init2(timop, &umtime); } - return (do_cv_wait(td, uap->obj, uap->uaddr1, ts, uap->val)); + /* only HW clock id will work. */ + if (timop != NULL && (timop->clockid < CLOCK_REALTIME || + timop->clockid >= CLOCK_THREAD_CPUTIME_ID) && + timop->clockid != CLOCK_TAI) + return (EINVAL); + + return (do_cv_wait(td, cv, uap->uaddr1, timop, wflags)); } static int diff --git a/sys/sys/umtx.h b/sys/sys/umtx.h index f7a69ae772c3..1cd9e2070977 100644 --- a/sys/sys/umtx.h +++ b/sys/sys/umtx.h @@ -115,6 +115,7 @@ #define CVWAIT_CHECK_UNPARKING 0x01 #define CVWAIT_ABSTIME 0x02 #define CVWAIT_CLOCKID 0x04 +#define CVWAIT_UMTX_TIME 0x08 #define UMTX_ABSTIME 0x01