From nobody Mon Aug 3 00:25:29 2026 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 4hCyBL1cKsz6mj0n for ; Mon, 03 Aug 2026 00:25:30 +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 4hCyBK6PJwz4P15 for ; Mon, 03 Aug 2026 00:25:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785716729; 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=2r3/e3/y2XifHd2qBrgnGbStZQusnelc8PkeIWNrz7c=; b=K0CAH5k5DtMyFcOncYlfOo6X7JLsP9oZ/tE/6J0Fub2KvYZpEpDHz+9Ap0mZUIm2AHJy4/ a6QRU/JcSM7egNyLidgzeZ62xantdObYUBiN18sozZDk5KhiHYpsVfze6tkGhF4CtNDa/y Ca43bRScuZ57snb6gD/g2+TqQCH7JBl/B1F9iiJGASk+tphE5WJ2Nwql3ZH3AjBptEWJKs b+COUSDWZlRW6EqQE05svo3YF2AS5SNzWPM6LQnfQvmTiYgl7Q0whfUiIz8TMlAYU46YUA Q5BGGsRc93IgGA09OKJtKH1GwJh+OQ5cXiKB7Ri/Dli1IIqbXXaW66j39M/log== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1785716729; a=rsa-sha256; cv=none; b=k9eJg7zkST3H/V8Zgb+yNaufj0d3tDcf4zektbRqU0mb+LuddtVLYTMZbQv9izm07wg6Ms cvjRZWkLE3mfb4mk7he6JC0tFoT2dWD2BL659FyvySDg5MWSs+Zy3ICl6xviLd6XOR9kt1 Nfz5HqHeYglUdJbB9FmsIS72FEZBs7jGe5nfcQp5VgoO5HnCoyUZTEtsLyixl8Way8IWwe Zf52CwT+baZFuuJBdfxi5RVLrk1yTTeAS34Ut+psqGVQRa5ITx4YkW1VyR/qO7q29KhSXT LYYKSeRnPD6Lm4vYh9B7eB573lO+J+PBgl7GkBQ8SnsvnUkXoCLyFTmPWAVI5Q== 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=1785716729; 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=2r3/e3/y2XifHd2qBrgnGbStZQusnelc8PkeIWNrz7c=; b=gwodZ7ZcvxKrRPGfVtpzAEmzj7iP8az6EAHsz7gxeJ5220gCCVN7tFaaYF1vl/uibgcyxy yKMszFnSnoxnVWWoF9kTsWmwAPz/OV8fc2baQ6uS1q1G8lYmXdWveMzjakRA6Hk3mhYwEd fLqcgc3D4GjZQwmNPyWW3tGdLrCZHnUXKmjbMcGRNzNoowezFfV26h0z2AF9ibc3BMH5AK UnwNnAyBTwQYBrGKdTVVJ9195gttSUDS/uC5slthBMrKhuBf+JNiyZ9s4e41/sd1fOeUN5 ppxPAJgspLI9paV0S5FxkLt9UHZhVAzt7/9RLvW9MYGAjekVUCYL0KtKlaiRUg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hCyBK52Rrzf0H for ; Mon, 03 Aug 2026 00:25:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1ce8c by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 03 Aug 2026 00:25:29 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 16015bf932bd - stable/15 - umtx_op(2): add the CVWAIT_UMTX_TIME flag for the UMTX_OP_CV_WAIT_UC request 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 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/stable/15 X-Git-Reftype: branch X-Git-Commit: 16015bf932bde4ab4cb174634ba6ef48fdad5fdc Auto-Submitted: auto-generated Date: Mon, 03 Aug 2026 00:25:29 +0000 Message-Id: <6a6fdff9.1ce8c.2f76fad7@gitrepo.freebsd.org> The branch stable/15 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=16015bf932bde4ab4cb174634ba6ef48fdad5fdc commit 16015bf932bde4ab4cb174634ba6ef48fdad5fdc Author: Konstantin Belousov AuthorDate: 2026-07-25 22:30:37 +0000 Commit: Konstantin Belousov CommitDate: 2026-08-03 00:23:14 +0000 umtx_op(2): add the CVWAIT_UMTX_TIME flag for the UMTX_OP_CV_WAIT_UC request (cherry picked from commit d738f66fab9208ee3bccea5fed293d8ce3ee5ca3) --- 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