From nobody Mon Jul 27 16:17:52 2026 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 4h83fZ0L14z6nBqV for ; Mon, 27 Jul 2026 16:17:58 +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 4h83fY4KK1z438V for ; Mon, 27 Jul 2026 16:17:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785169077; 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=mKM3+aiO3ByFGULtFPniGlSEodj7vVezHl0u6Vgf+f+hOdGrw1MV0iJrI02q5CnwQPakqw PEJ1gLiY83FogX7VQ9HYhDxi2b/XcYDEdYRfdSz1bUR343FK866iJYavrbzE12mwwIJylM Vw63k2wAWc51qdfQ1OXPSarymz807RRPxy42n8mjado+W1/0dKa6FBe4HQJ/qVVsH2hZuk 116gcENUXjfLuMv2tkAA74ghicdVyFNWt5d5hZi3np0b/8a42TwyaGwb/e0NmWHVre82eB M6TlWXLNhGCgHNZrlzM5rL/cG74UC2mRG+UTXgXXVuO2aoapsX+daFHjAPmgKQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1785169077; a=rsa-sha256; cv=none; b=cGX5UEvRWYW/91cUMG6jRTGDfd9h+Y6TRRKic4/D7pU1QsrXtsinCkjDBNXxbzI2vncw3m K7Qe28BSmdWDasDdurNvnLF3cLqCRhpLPnOVpAST43fUqwiTWlyi+wVM40hqezF5TLFqkj 2ZSXSBGteYtASXrz7Reg1WuqeLmsWO76ZTDRqOMmej8D00E6ExKIydTnzuVEmZvvf9XY4V hGUm6gRMuyrd1jc3mubq47WuxkRUaMB7aZNAF6JmutrtZhTQKaRbj5hR91HJ9wmpfP4iy2 MhEgBbZiQm8UkuaPVxt/dGHZ/qwCI9q56Gnp/nEb03P3pbiklkGHXGPDk6Su7Q== 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=1785169077; 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=dM6O2csiLhb/AGm21Up1xn9M3QQ3Vh+ish+1Yon3TdTu7L/7R5satQFUWTeVxGgBdR7OTT NokOWpzNbxwtMPfzKCgOMybh/eHugUUTUfPHT8IC4vBW2RCbOlTNK+9WNcAzqNU6UZSldq ukGHwRDuY9XlYqqAIwFYysA8J3UEixY8pMKskZC3izk7jesIbEs/bjSAuU5Y0SLpUQ0rzv wFqiCg9sMSojghKM0Qz/kNFh9NvSljqzc8Ok62wVflPiWzWA67W3fmLyk5oWiO2mcag2ev ZH0pZ71hcvHTSjCExCJag6AWZepbikWS+RA2VqR9tk9mXywUO8GsXcexDGp4wA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4h83fY3H5Xz1FKS for ; Mon, 27 Jul 2026 16:17:57 +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 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 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