From nobody Tue Nov 26 14:48:58 2024 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 4XyQSV6pJZz5fYZX; Tue, 26 Nov 2024 14:48:58 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XyQSV3kDbz4WZt; Tue, 26 Nov 2024 14:48:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732632538; 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=t9/RrCScWsycGAXYZZvm51s2qDbRNFQgBoqHOe/mX/8=; b=lNFkLfzrDGUqE57WFK/RXoWA3zXjmXAsDrtj+1y+esYLJhwnuOtNJ9tVZuaY0qjutXSUNf PJXjsVgSpUXbJUTYhzFxI3K+gAlCwrSQMN8UoUfygVALDUoOv2vagCWiPv0GrRJgZFujSE xJOKPa9sz/mwxWA9/I8Ug5vG75ZYyjq1xAMMg0nbPQd7jyYbucr1YzmdA8QKrf+m028DHf Rm2jXXPBGzjViRLm4Uo5zYf1cCPIFNXPifCQ4Jn4P4kk3bvzu8+kTVt6tKIsW0IZd5mdTC ZDhPrhbvITpqwA/gMIXd70vneV6ynOvq+8nKSMzHm2EJg4UEx3yi74E2szj3mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732632538; 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=t9/RrCScWsycGAXYZZvm51s2qDbRNFQgBoqHOe/mX/8=; b=vTySDUKK9gp77DbIYjoMll2vs/ub2nLmdp57pTkkNnvZCcCUxl3b/ceB+7RaNoRKKa+EQf yD+Z12bxhWdOA8oDMXAHJ2kq6N7FoLcXJ244q3/RS+axY1Zlskc7CB1SYCpY+XLl3z3aLz I9Nsg3qtBnnFMqceW3GEVtNJ2rbVTO20n7np5N/fk70nZE2Td63RUeCcJ2gSVqVmZoLXye jeDuEp7stmJMOb7d17XwkSZLkoBs1VHW5Z7lVIIwopKCTnwJCJHohvqJ3OUWm8UMm9K1CX 76nNKOf1T81c8j/QG4SwQpAyB+Dl2FGnhNoxiefuTNSuV4JhjLlPz2CdtGeWSw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1732632538; a=rsa-sha256; cv=none; b=Nt+bN+PnbUo+ocsHd9Yym1xl9f9KAHdnteNbGOc09YusRqs0NvSYELYO4MuXzajehOFnN1 X2g5lr0IiEmRfLEMUUQIhXNtm8Verc6KQsdnzNXfb8Dj2v3FZiThjM9rp7J+hFbVcj3j5O hyhdqb41fOiYmuLV5ah4Xt97P9wsL0avjOtPf+MOjAQAmye2+Waj4WJxwZCTlU+bt09+Pa jYkUg+LXrf6ZHxxsgN0dKwj0Uzg7houw6aYclV0I2PuoT9HQMniyG2nGZqWvR1MccNQmxS GkaLpiA0wPp1z/pdiddtvchLr+xXBV6+JD18s7hFgAsl/SMzN09wmbFeqkCwZg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XyQSV3LVXzSvT; Tue, 26 Nov 2024 14:48:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4AQEmwA6084211; Tue, 26 Nov 2024 14:48:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4AQEmw7Y084208; Tue, 26 Nov 2024 14:48:58 GMT (envelope-from git) Date: Tue, 26 Nov 2024 14:48:58 GMT Message-Id: <202411261448.4AQEmw7Y084208@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Christos Margiolis Subject: git: 5317480967bf - main - sound: Remove CHN_F_SLEEPING 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 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: christos X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5317480967bfc8bf678e4da3fce81bcb3f5b7836 Auto-Submitted: auto-generated The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=5317480967bfc8bf678e4da3fce81bcb3f5b7836 commit 5317480967bfc8bf678e4da3fce81bcb3f5b7836 Author: Christos Margiolis AuthorDate: 2024-11-26 14:48:36 +0000 Commit: Christos Margiolis CommitDate: 2024-11-26 14:48:36 +0000 sound: Remove CHN_F_SLEEPING The KASSERT in chn_sleep() can be triggered if more than one thread wants to sleep on a given channel at the same time. While this is not really a common scenario, tools such as stress2, which use fork() and the child process(es) inherit the parent's FDs as a result, we can end up triggering such scenarios. Fix this by removing CHN_F_SLEEPING altogether, which is not very useful in the first place: - CHN_BROADCAST() checks cv_waiters already, so there is no need to check CHN_F_SLEEPING as well. - We can check whether cv_waiters is 0 in pcm_killchans(), instead of whether CHN_F_SLEEPING is not set. Reported by: dougm, pho (stress2) Sponsored by: The FreeBSD Foundation MFC after: 2 days Reviewed by: dev_submerge.ch, markj Differential Revision: https://reviews.freebsd.org/D47559 --- sys/dev/sound/pcm/channel.c | 13 +------------ sys/dev/sound/pcm/channel.h | 4 ++-- sys/dev/sound/pcm/sound.c | 4 ++-- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c index 59cdb8cd07f5..f619ddd4bc35 100644 --- a/sys/dev/sound/pcm/channel.c +++ b/sys/dev/sound/pcm/channel.c @@ -309,14 +309,7 @@ chn_wakeup(struct pcm_channel *c) if (CHN_EMPTY(c, children.busy)) { if (SEL_WAITING(sndbuf_getsel(bs)) && chn_polltrigger(c)) selwakeuppri(sndbuf_getsel(bs), PRIBIO); - if (c->flags & CHN_F_SLEEPING) { - /* - * Ok, I can just panic it right here since it is - * quite obvious that we never allow multiple waiters - * from userland. I'm too generous... - */ - CHN_BROADCAST(&c->intr_cv); - } + CHN_BROADCAST(&c->intr_cv); } else { CHN_FOREACH(ch, c, children.busy) { CHN_LOCK(ch); @@ -332,15 +325,11 @@ chn_sleep(struct pcm_channel *c, int timeout) int ret; CHN_LOCKASSERT(c); - KASSERT((c->flags & CHN_F_SLEEPING) == 0, - ("%s(): entered with CHN_F_SLEEPING", __func__)); if (c->flags & CHN_F_DEAD) return (EINVAL); - c->flags |= CHN_F_SLEEPING; ret = cv_timedwait_sig(&c->intr_cv, c->lock, timeout); - c->flags &= ~CHN_F_SLEEPING; return ((c->flags & CHN_F_DEAD) ? EINVAL : ret); } diff --git a/sys/dev/sound/pcm/channel.h b/sys/dev/sound/pcm/channel.h index 79a8d35b22f7..d226adfba06b 100644 --- a/sys/dev/sound/pcm/channel.h +++ b/sys/dev/sound/pcm/channel.h @@ -354,7 +354,7 @@ enum { #define CHN_F_RUNNING 0x00000004 /* dma is running */ #define CHN_F_TRIGGERED 0x00000008 #define CHN_F_NOTRIGGER 0x00000010 -#define CHN_F_SLEEPING 0x00000020 +/* unused 0x00000020 */ #define CHN_F_NBIO 0x00000040 /* do non-blocking i/o */ #define CHN_F_MMAP 0x00000080 /* has been mmap()ed */ @@ -381,8 +381,8 @@ enum { "\002ABORTING" \ "\003RUNNING" \ "\004TRIGGERED" \ + /* \006 */ \ "\005NOTRIGGER" \ - "\006SLEEPING" \ "\007NBIO" \ "\010MMAP" \ "\011BUSY" \ diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c index 4b7bcc64397f..218147b73db0 100644 --- a/sys/dev/sound/pcm/sound.c +++ b/sys/dev/sound/pcm/sound.c @@ -221,8 +221,8 @@ pcm_killchans(struct snddev_info *d) /* Make sure all channels are stopped. */ CHN_FOREACH(ch, d, channels.pcm) { CHN_LOCK(ch); - if ((ch->flags & CHN_F_SLEEPING) == 0 && - CHN_STOPPED(ch) && ch->inprog == 0) { + if (ch->intr_cv.cv_waiters == 0 && CHN_STOPPED(ch) && + ch->inprog == 0) { CHN_UNLOCK(ch); continue; }