From nobody Fri May 22 14:57:10 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 4gMSzp3qgfz6dwft for ; Fri, 22 May 2026 14:57:10 +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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gMSzp22t1z3VlG for ; Fri, 22 May 2026 14:57:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1779461830; 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=UhrE69UwamrhLsgbQaX0qS1UCO1t+EKIOtQafI5rZ0s=; b=Sq/vfSb76pr3BWkkfEvw3JQb777lAQezq61pyYAXsutP6xT/rB7aipdqYF8/HeNRIa1hOQ NNJ1nKRlT+wjkZpQtVSPGjEa7iv45+szmkSKUKHmfaT2WL57RuDQC1nkTq865oS8d2a2eh KFeYLf14VYSkkb5yEvOE/mwE50OtcNTnm88rAhE3Xxl8HoMSioLVoaX1C/poQEsVufNstL Zh4JqHdt6tBno3kRiGLEt6wb6s+UAidIAeEjpJEgtgtV4NlJ0BHbkQXfwjfbbpe49RX5fF n1q8PvQEDIvN3UVZXLxP3FNVom+AJwXEwDrBmhJPFBKX0wNyctxUUXJ7Oyq6qQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1779461830; a=rsa-sha256; cv=none; b=g8HIPwL8Nw0mB6yhq/Gu7DvCQ+Qh+j3OKFbfo8rww50xwxjYFglXnnpsZ0pQOMwMyf1SOi jvybBXFeyfFynj94L2kCP2m/wAlxmuEfAh9LVUvWElFJfW/4ePD/nCyblfFuHtMDjEXLC9 14zdiUT3ffWLvwA9EPC44jrKzTZeFX2dngJPxetJ+aHWaQJ56+nVsl6Eku8AmjTvftzJJr uBSHIyCcyg9g3T9o9/6Ped7Z4tV+xBOJlZE5uVwSvLfY+hIZTCSqxs+LJpLma1qowmu5cG tMVFNdOYqN5XLk1a1XZvh40HJTKDmZGt8KK3nyNn+9ev1tipPK8QBZzGxkuzyA== 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=1779461830; 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=UhrE69UwamrhLsgbQaX0qS1UCO1t+EKIOtQafI5rZ0s=; b=jgNLWrPeS4TcE+1gEv58VjXfPUvVcNDCC0ZdQlpOR5fPpsGw7WBMtS+taVm/fu0oGIRhqK XRVJy1xJPbtMt0GQC0MSaqVuPfMfSmT6D0CzV8PFWj9WQxfFQaZwNFhhyDBOOkO3M9nyo+ +3MQvIrV7M++wFVp1v5tl0B/iZNDFu2cLKF03YctjxEX5iFlZNMGhgsyMZOUzKdnqAsvgw DYgOVOfYCx6SSPCF7VTxEszKc6QZxx/714NaIq/X1VUDjxqDCfoBinGt2jCVVy2H4iWwsW Fb4SQJrwhK63no3C8+1j3Sm8s2B8SW6HXfC7j9VilyS6gIXJr6pPu6fYnZgwbw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gMSzp1fSKz9Nh for ; Fri, 22 May 2026 14:57:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1df0b by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 22 May 2026 14:57:10 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: c9546bb61910 - main - tests/procdesc: Use a more efficient mechanism to block List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c9546bb61910d40f4cb0dfb9716ba6eba44d1a0d Auto-Submitted: auto-generated Date: Fri, 22 May 2026 14:57:10 +0000 Message-Id: <6a106ec6.1df0b.241bdf1d@gitrepo.freebsd.org> The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=c9546bb61910d40f4cb0dfb9716ba6eba44d1a0d commit c9546bb61910d40f4cb0dfb9716ba6eba44d1a0d Author: Mark Johnston AuthorDate: 2026-05-22 14:56:47 +0000 Commit: Mark Johnston CommitDate: 2026-05-22 14:56:47 +0000 tests/procdesc: Use a more efficient mechanism to block Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D57149 --- tests/sys/kern/Makefile | 2 +- tests/sys/kern/procdesc.c | 41 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/tests/sys/kern/Makefile b/tests/sys/kern/Makefile index d7a6af905b7e..dcaeb8d2f1fa 100644 --- a/tests/sys/kern/Makefile +++ b/tests/sys/kern/Makefile @@ -106,7 +106,7 @@ LIBADD.kcov+= pthread CFLAGS.ktls_test+= -DOPENSSL_API_COMPAT=0x10100000L LIBADD.ktls_test+= crypto util LIBADD.listener_wakeup+= pthread -LIBADD.procdesc+= pthread +LIBADD.procdesc+= kvm pthread LIBADD.shutdown_dgram+= pthread LIBADD.socket_msg_waitall+= pthread LIBADD.socket_splice+= pthread diff --git a/tests/sys/kern/procdesc.c b/tests/sys/kern/procdesc.c index 2d710ef057f2..2fe50be45bf7 100644 --- a/tests/sys/kern/procdesc.c +++ b/tests/sys/kern/procdesc.c @@ -33,15 +33,50 @@ #include #include +#include #include #include #include #include #include +#include /* Tests for procdesc(4) that aren't specific to any one syscall */ +/* + * Block until a thread in the specified process is sleeping in the specified + * wait message. + */ +static void +wait_for_naptime(pid_t pid, const char *wmesg) +{ + kvm_t *kd; + int count; + + kd = kvm_openfiles(NULL, "/dev/null", NULL, O_RDONLY, NULL); + ATF_REQUIRE(kd != NULL); + for (;;) { + struct kinfo_proc *kip; + int i; + + usleep(1000); + kip = kvm_getprocs(kd, KERN_PROC_PID | KERN_PROC_INC_THREAD, + pid, &count); + ATF_REQUIRE(kip != NULL); + for (i = 0; i < count; i++) { + ATF_REQUIRE(kip[i].ki_stat != SZOMB); + if (kip[i].ki_stat == SSLEEP && + strcmp(kip[i].ki_wmesg, wmesg) == 0) + break; + } + if (i < count) + break; + } + + kvm_close(kd); +} + /* * Even after waiting on a process descriptor with waitpid(2), the kernel will * not recycle the pid until after the process descriptor is closed. That is @@ -128,8 +163,7 @@ ATF_TC_BODY(poll_close_race, tc) error = pthread_create(&thr, NULL, poll_procdesc, &pd); ATF_REQUIRE_MSG(error == 0, "pthread_create: %s", strerror(error)); - /* Wait for the thread to block in poll(2). */ - usleep(250000); + wait_for_naptime(getpid(), "select"); ATF_REQUIRE_MSG(close(pd) == 0, "close: %s", strerror(errno)); @@ -159,8 +193,7 @@ ATF_TC_BODY(poll_exit_wakeup, tc) error = pthread_create(&thr, NULL, poll_procdesc, &pd); ATF_REQUIRE_MSG(error == 0, "pthread_create: %s", strerror(error)); - /* Wait for the thread to block in poll(2). */ - usleep(250000); + wait_for_naptime(getpid(), "select"); ATF_REQUIRE_MSG(pdkill(pd, SIGKILL) == 0, "pdkill: %s", strerror(errno));