From nobody Thu Oct 29 17:44:41 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 4jFs7G0N11z6xNxp for ; Thu, 29 Oct 2026 17:44:42 +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 4jFs7F4k26z3Frn for ; Thu, 29 Oct 2026 17:44:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793295881; 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=Kd1JHYwJNBAjSixuOGxoWLuqHGaV6If/KjenEWLyvXY=; b=ahbiOaIfAKL6qy7eKLkgQrhkwfD6OkmusmBDUgRiYAdBxAmMYmz+EgGW5P5k3YujBpD6iY Nnq15ZnBT4WFHcHURaQIYpMmORUTlN90zWrcu9UDkXRkpDw35Y+uO5xQAYR7mjMh/gYIgn xbl2D22k2WFrmZ27qyUgBEAj0tIvQ7ZgcRl6Vud1EoOaLgivPh0m1AuKwsmOStF2mUNCwi OXDWLP7QrQNd5dE3DPei7PQNmOIADuOjunb6uv2I/YFTXESiUrw7202flaeivCCINQ0w/x Ve78i0nDc6ghIsDPBmIqN0FCzKNRUoj81CfHbhbb4Zmwwf58aAaTL7zuhqn6Pg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793295881; b=gQmhe8D8cloRqC9sO4ekwXuW5f+Q7HvC955j20iTTUeh2NuEm9Y9t08Z8xBUB2wBu6KgIm 7H9+opEB9ggxGJQ6x1j4cqOreoJsP1KPTFh77NrBNEOZBZnE6ZUdTrP3shnyZv9l4zwxkp 6l9aTsYSfrLP/MqifiOeCxxWKhlVUoSpn7NsO+0yiJ8iM4PB5AE6FYQzpDKHJZfZ3KzGuE EUFro4ttsm6bal3sx3jIbLdthE82OFJGVVSJ0KpcXftDWdVsuVH9DbLJlArV9zGjC3WFAi jBM9HfuzQvggCxTbOy/0ktt3xQ60DsuQW1RPyy7brRg7VI2Y2H7XAQ7CZLHcrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793295881; 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=Kd1JHYwJNBAjSixuOGxoWLuqHGaV6If/KjenEWLyvXY=; b=rJujySwYEQIUac6l1+t/q64VFw+v7Ja155gaPjMP+TnK55MM7tx8bvf9D1lNqE2ttmVzss WrGW2p96aw3L7/3KikdupDlrIQ6fD3I7VU3UyDnqrdkarj0Uw7KUsBn5yXh2UyuoP34LXx Vn/iS7oH04gHuyM27q3vg4r83vrYruLtaRtX8ODPBDn8oSDh7+7QRXPHN5ARh4orPCV0Gu SP3K/je5WBkl0ym6eHZ5fcN4E7vH/OH8VBcRPBAGtreXvqN2ZQ5JzBN6Vt6rTVFlzAQfv0 orja682EOYq9Mi8fqCSw/q8q98y7R35BKruZNIid+yZzBbX6im8Ol9zTBt9huA== 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 4jFs7F4NLvzqjK for ; Thu, 29 Oct 2026 17:44:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3ce69 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 29 Oct 2026 17:44:41 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: ShengYi Hung Subject: git: 56a490f9c5e6 - main - libthr: Robust tryjoin test List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches 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: aokblast X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 56a490f9c5e64f2ee346fc93332c7ab78f9237c4 Auto-Submitted: auto-generated Date: Thu, 29 Oct 2026 17:44:41 +0000 Message-Id: <6ae38609.3ce69.6cd7d16a@gitrepo.freebsd.org> The branch main has been updated by aokblast: URL: https://cgit.FreeBSD.org/src/commit/?id=56a490f9c5e64f2ee346fc93332c7ab78f9237c4 commit 56a490f9c5e64f2ee346fc93332c7ab78f9237c4 Author: ShengYi Hung AuthorDate: 2026-10-18 02:15:18 +0000 Commit: ShengYi Hung CommitDate: 2026-10-29 17:44:15 +0000 libthr: Robust tryjoin test We cannot actually rely on a status (finish) before thr_exit. The thread needs the kernel signal status=1 to userspace. Before that, any tryjoin fails. The previous one works as we sleep 1 and should be enough for normal case. Reviewed by: kib, markj MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D60832 --- lib/libthr/tests/Makefile | 1 + lib/libthr/tests/pthread_tryjoin_test.c | 29 ++++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/lib/libthr/tests/Makefile b/lib/libthr/tests/Makefile index 5ffcd7b046c8..f738c3268c56 100644 --- a/lib/libthr/tests/Makefile +++ b/lib/libthr/tests/Makefile @@ -40,6 +40,7 @@ ATF_TESTS_C+= pthread_tryjoin_test LIBADD+= pthread LIBADD.fpu_test+= m +LIBADD.pthread_tryjoin_test+= kvm LIBADD.sem_test+= rt BINDIR= ${TESTSDIR} diff --git a/lib/libthr/tests/pthread_tryjoin_test.c b/lib/libthr/tests/pthread_tryjoin_test.c index ba88ac2ed6f5..ca92f8e25228 100644 --- a/lib/libthr/tests/pthread_tryjoin_test.c +++ b/lib/libthr/tests/pthread_tryjoin_test.c @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include #include #include @@ -22,11 +24,22 @@ static void * thr_fun(void *arg) { while (atomic_load_explicit(&finish, memory_order_relaxed) != 1) - sleep(1); - atomic_store_explicit(&finish, 2, memory_order_relaxed); + usleep(1000); return (arg); } +static int +thread_count(kvm_t *kd, pid_t pid) +{ + struct kinfo_proc *kip; + int count; + + kip = kvm_getprocs(kd, KERN_PROC_PID | KERN_PROC_INC_THREAD, pid, + &count); + ATF_REQUIRE(kip != NULL); + return (count); +} + ATF_TC(pthread_tryjoin); ATF_TC_HEAD(pthread_tryjoin, tc) { @@ -37,8 +50,13 @@ ATF_TC_HEAD(pthread_tryjoin, tc) ATF_TC_BODY(pthread_tryjoin, tc) { pthread_t thr; + kvm_t *kd; void *retval; - int error, x; + int error, nthr, x; + + kd = kvm_openfiles(NULL, "/dev/null", NULL, O_RDONLY, NULL); + ATF_REQUIRE(kd != NULL); + nthr = thread_count(kd, getpid()); error = pthread_create(&thr, NULL, thr_fun, &x); ATF_REQUIRE_EQ(error, 0); @@ -47,8 +65,9 @@ ATF_TC_BODY(pthread_tryjoin, tc) ATF_REQUIRE_EQ(error, EBUSY); atomic_store_explicit(&finish, 1, memory_order_relaxed); - while (atomic_load_explicit(&finish, memory_order_relaxed) != 2) - sleep(1); + while (thread_count(kd, getpid()) != nthr) + usleep(1000); + kvm_close(kd); error = pthread_tryjoin_np(thr, &retval); ATF_REQUIRE_EQ(error, 0);