From nobody Sun Oct 04 00:34:23 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 4hy3Rz4kc4z4TnZp for ; Sun, 04 Oct 2026 00:34:23 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hy3Rz46Zsz4H7s for ; Sun, 04 Oct 2026 00:34:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791074063; 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=i83p31SUtRC6VRDUU0tD7aKAxsBbQuR1DssTTo4A5Ac=; b=EeFdNaihptChQS1U0KBvXrCvoc6LoR2ExlaEgjjw5Jh/U80Lyh9QMjZfB1MhkeX8LKbNwe jtmi4z3h+sSp6JNSqcYNIiSMCzFLlBrY1rXo0++VCJPNYfL6owkqmJGoTYspMbZqFf2Buy 9rVE6/Zc7XY5V2j11juj3L5+5iNSm+9bGUfniNBG6tgCGdDbLhoZiNp3zWyMsuorx6Capr xCKtpPxkFOogwITRDa6SdgPaPMAqqcizrMqHS8TYEuHW+iox9PsnMN2N7S2ZVVmtElFMAK UzhGQvdygpkBOI8H7s2F1ZZLdit55wxkP7dYLcVUpbdAN678vVIi0+49BHGyXw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1791074063; b=ZC+C8s3P3DmS5tinHgIbcFXdYrtTYZPQf7r9Qims71hcyGm1zPZE/kK5gP4XzI7UBOMR3m yGxIMKHmMx3qzsY7b6jSxkzahomHcbKTmqPxhhPRtFY/rqcCpFU/Fbl/RJvMy1A7NEe2hX qf4Yv3XjlissP909R70AHuOLKozit0xbfGBt0LAZqudMSy2xSn+WpA/Ad+/TS7L7OPLCwy VoRQkuQhuyVZAjjz5wj1cpPglARG7ldhcEqqOevtUeBchzzxJQL2JT1DFebyIK0F50XlQT Pcw2RzvJafHF6Rk6eRUX/ikZci6MouzMqQ7G4kxNNAgMtb7YdU9GNnbT3IvhEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791074063; 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=i83p31SUtRC6VRDUU0tD7aKAxsBbQuR1DssTTo4A5Ac=; b=oCCYt/raJvZyaF3VwTE3/VLnU7mn+wbif2dSgh9annH3ccXk0gDiIh0pU5xYnj/XWPq0XC lVR4VD8ZaDFFf2iHUDjYQKa5QYylY7F4GWB7NDAoyEYsJyrItcGcY93oyxpxEYL+Mxi4VZ XVYR007RtLf6mJ6HuXYi3MC0oUZBWjQFZcsVxUXg3kSwOVLJ8KkLs0Xi+9+e6zebr20zSd aE9cYRDPbyOf4Vx7lH1cjWVx44jjfkJ0LfJ9Dyv0ahYJyBSFS0i/x4IbS/1i/nFm9+vq/9 Z5wWHCPz7r+l9C8X1D6AZwzj7Ftf1FyC0C5JOaenoU/F+7dN1Qd6cijAYN2xSg== 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 4hy3Rz39V0z1Pmc for ; Sun, 04 Oct 2026 00:34:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 33dee by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 04 Oct 2026 00:34:23 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: e831067d51b4 - stable/15 - libthr: GC pshared locks not more than each 25msecs by default 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: e831067d51b422e7350a0962ba77ffc68b10a045 Auto-Submitted: auto-generated Date: Sun, 04 Oct 2026 00:34:23 +0000 Message-Id: <6ac19f0f.33dee.4a74f892@gitrepo.freebsd.org> The branch stable/15 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e831067d51b422e7350a0962ba77ffc68b10a045 commit e831067d51b422e7350a0962ba77ffc68b10a045 Author: Konstantin Belousov AuthorDate: 2026-09-27 22:16:33 +0000 Commit: Konstantin Belousov CommitDate: 2026-10-04 00:33:40 +0000 libthr: GC pshared locks not more than each 25msecs by default PR: 268532 (cherry picked from commit 4472a048cf95c9c1593a8b04655a59096b44b0c9) --- lib/libthr/thread/thr_init.c | 3 +++ lib/libthr/thread/thr_private.h | 1 + lib/libthr/thread/thr_pshared.c | 25 ++++++++++++++++++++++--- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/lib/libthr/thread/thr_init.c b/lib/libthr/thread/thr_init.c index 0f9e3749d75f..162ef7dfe7a9 100644 --- a/lib/libthr/thread/thr_init.c +++ b/lib/libthr/thread/thr_init.c @@ -539,6 +539,9 @@ init_private(void) mint, NULL, NULL); } } + env = getenv("LIBPTHREAD_PSHARED_LOCK_DESTROY_IMMEDIATE_GC"); + if (env) + __thr_pshared_destroy_imm_gc = true; } init_once = 1; } diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h index d7b889930365..2edf09d761ae 100644 --- a/lib/libthr/thread/thr_private.h +++ b/lib/libthr/thread/thr_private.h @@ -780,6 +780,7 @@ extern struct pthread *_single_thread __hidden; extern bool _thr_after_fork __hidden; extern int __thr_new_flags; +extern bool __thr_pshared_destroy_imm_gc __hidden; /* * Function prototype definitions. diff --git a/lib/libthr/thread/thr_pshared.c b/lib/libthr/thread/thr_pshared.c index d20d66e21ea3..698cc5e6adc7 100644 --- a/lib/libthr/thread/thr_pshared.c +++ b/lib/libthr/thread/thr_pshared.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "namespace.h" #include #include "un-namespace.h" @@ -49,6 +50,10 @@ static struct pshared_hash_head pshared_hash[HASH_SIZE]; static struct urwlock pshared_lock = DEFAULT_URWLOCK; static int page_size; +#define GC_INTERVAL_USEC 25000 +static struct timeval pshared_gc_time = {0, 0}; +bool __thr_pshared_destroy_imm_gc = false; + void __thr_pshared_init(void) { @@ -94,9 +99,8 @@ pshared_unlock(struct pthread *curthread) * mapped off-page. * * Mitigate the problem by checking the liveness of all hashed keys - * periodically. Right now this is executed on each - * pthread_lock_destroy(), but may be done less often if found to be - * too time-consuming. + * periodically. Right now this is executed on pthread_lock_destroy() + * if previous gc happen later than 25msecs. */ static void pshared_gc(struct pthread *curthread) @@ -104,8 +108,18 @@ pshared_gc(struct pthread *curthread) struct pshared_hash_head *hd; struct psh *h, *h1; int error, i; + struct timeval now, diff; pshared_wlock(curthread); + + if (!__thr_pshared_destroy_imm_gc && gettimeofday(&now, NULL) == 0) { + timersub(&now, &pshared_gc_time, &diff); + if (diff.tv_sec == 0 && diff.tv_usec < GC_INTERVAL_USEC) { + pshared_unlock(curthread); + return; + } + } + for (i = 0; i < HASH_SIZE; i++) { hd = &pshared_hash[i]; LIST_FOREACH_SAFE(h, hd, link, h1) { @@ -118,6 +132,11 @@ pshared_gc(struct pthread *curthread) free(h); } } + + if (!__thr_pshared_destroy_imm_gc && gettimeofday(&now, NULL) == 0) { + pshared_gc_time = now; + } + pshared_unlock(curthread); }