From nobody Tue Nov 10 19:54:20 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 4jPHRJ2Gq6z6vLl3 for ; Tue, 10 Nov 2026 19:54:20 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jPHRJ1lYWz3NGS for ; Tue, 10 Nov 2026 19:54:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794340460; 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=qiORHjvbjT7bhAvWc0/hvxU2gfSV01kNrIb6UTheDsg=; b=WGwk0Ff0o/vWrd2IIGdKd2IAHx5XKJ9kLJtSqupNd5anx00LF2mn8AY/DFTOFiTSg4vB9z fkS/4QZvGSKdy7Ft9hpfjeFtsvkn9Mk/gdnbPzvvDF6zbB4FTBUjt2UXbhz0heTncfS4nn 1DKYNH/x7/r9JbBdXv3pRlGzsz227Ut9RFfZqvYwD76jcSctzavrdoyIDDBFpCPLBgOssJ 9IRfY27XbHkdle6x8lQYIgthrI3M9GdDG4Up6xahZGOF0qoGkST8zTSneRa++NHCZHDXf1 GXMf/LJkqTYXbxE4mNbu6djz1ZGrhOREZvl8m58X5N0a+G41u/ZEaAUNkukq9Q== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794340460; b=YIPSLxbNxnPUbxIxhRMLRxk0N3QqRIoOX5ax0QJY/2xRwleVL5mDUIk/xtqbTMcjw75b0M iTcLsPAZ69i37MQag76vlSYgLKxwQtfSRiiTD6u2RUNvWGtOpeh2L0BlGD95U8uNWmfNwA 85YSnt0Pxsq0bTa9q216gZXHNH1A+JHoHXy4SLZTjy6V2i9SV/Vz6VmaGkTkfxM81TNhif C0CMBb2ivUx+6qDhlHZoQpcPFouSUR46s/Vs1sW0gyfjQJx3WCqf/3t74t4De9PzoXDeYB ujHWfsoV1N9GR73mPkJz4CoWxOvd1E85bjpd0pURi9VevE0KpfyTOV4M9aCF3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794340460; 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=qiORHjvbjT7bhAvWc0/hvxU2gfSV01kNrIb6UTheDsg=; b=PhKZL8e7FB4oapH9edIKg/WV0/4J5Io8JLkcEwGyMTkwhprymsBn7gxsqDfsphD9TPWr69 QZ8soNGVuujmlHTf2MFH0/bIKNzqIdzpv9RC6mwtXrND5B6AlMBSptx7agmkEO15gL1XDx FRfblHZu5p6usSDNfUrkUAu07yW5v1ia1uuQoxCnOcvIWeSruI2Vm4GDbt3vEowJHNDyuu IgjXGp/jBnnAQxJJVJYjsUKAGTZWUy4mA7omDSyLUrkrmmSNyRDAJM9C9jXjDa1UPbT1Q2 V8EuA/U6TZsuw1ckW4imGnfaGxVTpFL3IY+L+7+ggrurNsvjz/V/XoVNPW1veg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jPHRJ16S8zjH8 for ; Tue, 10 Nov 2026 19:54:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 220b by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 10 Nov 2026 19:54:20 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 1b4779eef93c - main - libthr mutex_self_lock(): handle signals and clock steps List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main X-BeenThere: dev-commits-src-main@freebsd.org List-Id: Commit messages for the main branch of the src repository 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: 1b4779eef93c6e3c9af1887b941d7700ef143951 Auto-Submitted: auto-generated Date: Tue, 10 Nov 2026 19:54:20 +0000 Message-Id: <6af3766c.220b.4fc5cfa1@gitrepo.freebsd.org> The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=1b4779eef93c6e3c9af1887b941d7700ef143951 commit 1b4779eef93c6e3c9af1887b941d7700ef143951 Author: Konstantin Belousov AuthorDate: 2026-11-10 03:07:01 +0000 Commit: Konstantin Belousov CommitDate: 2026-11-10 19:53:27 +0000 libthr mutex_self_lock(): handle signals and clock steps Relocking an owned NORMAL mutex with an absolute timeout has two issues: - nanosleep(2) is never restarted, so any caught signal causes an early ETIMEDOUT. - If CLOCK_REALTIME or CLOCK_TAI are stepped backward during the sleep, the call also returns ETIMEDOUT before the clock reaches the deadline. The kernel already polls CPU-time clocks and handles realtime steps. Use _thr_umtx_timedwait_uint() in a loop to handle both issues. Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D61381 --- lib/libthr/thread/thr_mutex.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c index 30ebdd15951f..346396d15acf 100644 --- a/lib/libthr/thread/thr_mutex.c +++ b/lib/libthr/thread/thr_mutex.c @@ -905,8 +905,9 @@ static int mutex_self_lock(struct pthread_mutex *m, const struct timespec *abstime, clockid_t clockid) { - struct timespec ts1, ts2; + struct timespec ts1; int ret; + u_int dummy; switch (PMUTEX_TYPE(m->m_flags)) { case PTHREAD_MUTEX_ERRORCHECK: @@ -932,8 +933,11 @@ mutex_self_lock(struct pthread_mutex *m, const struct timespec *abstime, clock_gettime(clockid, &ts1) == -1) { ret = EINVAL; } else { - TIMESPEC_SUB(&ts2, abstime, &ts1); - __sys_nanosleep(&ts2, NULL); + dummy = 0; + do { + ret = _thr_umtx_timedwait_uint(&dummy, + 0, clockid, abstime, 0); + } while (ret == 0 || ret == EINTR); ret = ETIMEDOUT; } } else {