From nobody Fri Nov 29 12:28:25 2024 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 4Y0CBy2V7Fz5f669; Fri, 29 Nov 2024 12:28:26 +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 4Y0CBx6Zbkz47mZ; Fri, 29 Nov 2024 12:28:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732883305; 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=LTvgX27CqGnVqstOiXqcM3Ip6DO2VURqvZDYHH56mFE=; b=rvFqVfRw/OWXkaEx1mSCZCXG5Ux0DjFUh+m/TiH5RMbwlyu66oz9jFifVFd5gU1sp4QRc9 5R+bQ/Xb/Ydb5uuDo6p4uejaDDs31S6jdaGp9t4kyINnC10xcIOhe3J0xFSpIGGptRXVyY NTvVMOzwzbcWTghFuXehX2bV8zJ262484+pcg9PdPT1iLWqlUSEr29Uo8SL/MKVsp5QZ2s UWDklzkSDeQtcfoTsOWZiImU1H1J29ffnOigzxJbh4+eTW1Z4Haw5BXy+DiDIK6l3xsqbm cXpArrNEVg1dXl48yHhApsF/pqshNdMye2+9P2xZ4zFXsjVDw3udR9xH1e+19g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732883305; 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=LTvgX27CqGnVqstOiXqcM3Ip6DO2VURqvZDYHH56mFE=; b=h5nioD4B3dIXxpi4iC82Y6uOtkZO0sbDkf7UcPm4cWmiwFWWeBX4dDgii8DrQjHic9aMwc WLM9/dC+tL98595lZDTvAfcXSbiPIw3OlVYhWNbASzLmUhFRPdLjK1Mxuio1zGFxYPnTo2 PkloPTerq5kxCtJB+Ew4bBd6PLv00BB/uZ3Ed1IHNo9pnaOV5AZalt/7UVC0lrQuQjemhc YAGMZNqXhbn3FpOazKPhQ+l4j/y1Oi6CP81mVkaJIeCQPnajsZyU5uBPC4RdillRjw6ucX /pYsRAMSjNeroKJneB3kvjdEVYALUFTY0pAz4++qvJgtCPeD9j7ii7T7ohwsYA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1732883305; a=rsa-sha256; cv=none; b=NZW7KWG4+GuvCyorpR+fdwroFy/b5ThEvFrhJ8EP+0H67Z55qhDhSiQVuCXfJ7aI86e7XM P4xqUPRugZFMu7pIc4FdiFlUPiUV2iMQZYWPBY5bEA6xjlum3VgUrr9n5JeYusC1XKW+zj di/3ul1lBn3SBAhh4h/AKF9KAgJ/ui8VL/PISuvl1ihKGPqad79qYOlArCwP5I8bZS0NrG 7J4YDryrcvXVk7VFC0L35oEH5Gy0edjMKeeXSi3Xte8R07Azz5KORNgeJu+GkaD9n58zBm OLaI5YdeTb1JubD49LMn+1eANeDZgpTl+/P6kACKkq3dvZwoOeb0Tsv3aFKILg== 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 4Y0CBx4xk1zMxH; Fri, 29 Nov 2024 12:28:25 +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 4ATCSPlT070416; Fri, 29 Nov 2024 12:28:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4ATCSPEM070413; Fri, 29 Nov 2024 12:28:25 GMT (envelope-from git) Date: Fri, 29 Nov 2024 12:28:25 GMT Message-Id: <202411291228.4ATCSPEM070413@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Christos Margiolis Subject: git: 0ef520dca67a - stable/14 - sound: Remove CHN_F_SLEEPING List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/stable/14 X-Git-Reftype: branch X-Git-Commit: 0ef520dca67a0812d655cc4ee1b3db58dfb67e5f Auto-Submitted: auto-generated The branch stable/14 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=0ef520dca67a0812d655cc4ee1b3db58dfb67e5f commit 0ef520dca67a0812d655cc4ee1b3db58dfb67e5f Author: Christos Margiolis AuthorDate: 2024-11-26 14:48:36 +0000 Commit: Christos Margiolis CommitDate: 2024-11-29 12:28:07 +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 (cherry picked from commit 5317480967bfc8bf678e4da3fce81bcb3f5b7836) --- 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 44ba4805462d..761c505fd402 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; }