From: Takashi Iwai <tiwai@suse.de>
To: Cen Zhang <zzzccc427@gmail.com>
Cc: Takashi Iwai <tiwai@suse.de>,
perex@perex.cz, tiwai@suse.com, phucduc.bui@gmail.com,
cezary.rojewski@intel.com, cassiogabrielcontato@gmail.com,
kees+treewide@kernel.org, yilinzhang@moonshot.ai,
sammiee5311@gmail.com, kees@kernel.org,
thomas.weissschuh@linutronix.de, tglx@kernel.org,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
baijiaju1990@gmail.com, jjzuming@gmail.com
Subject: Re: [PATCH v2] ALSA: pcm: Unlink substreams before releasing them
Date: Thu, 15 Oct 2026 18:19:06 +0200 [thread overview]
Message-ID: <87h5in6io5.wl-tiwai@suse.de> (raw)
In-Reply-To: <CAFRLqsUY+RhE=CsMHAvcQtUmwE_hd4_WUhJKSJiwdUUE3a--Yg@mail.gmail.com>
On Thu, 15 Oct 2026 17:35:30 +0200,
Cen Zhang wrote:
>
> Hi Takashi,
>
> Takashi Iwai <tiwai@suse.de> 于2026年10月15日周四 15:18写道:
> >
> > The patch I submitted yesterday is such an attempt:
> > https://lore.kernel.org/20261014141212.316223-1-tiwai@suse.de
> >
> > Unfortunately it couldn't be reviewed by Sashiko, as it's based on my
> > latest tree. And now I noticed that there is still a potential race,
> > and fixed now. Will resubmit v2 patch.
> >
> >
> > thanks,
> >
> > Takashi
>
> After read the v2 patch. I also have a minor concern: is there still a
> lifetime window between snd_refcount_put() and snd_refcount_sync()?
>
>
> Suppose drain(A) has pinned B's runtime, and close(B) has completed
> unlink and drop. Could the following happen on two CPUs?
>
> drain(A) close(B)
> -------- --------
> finish_wait(&rt->sleep, &wait);
> snd_refcount_put(&rt->refcnt):
> decrement count to zero
> snd_refcount_sync(&rt->refcnt);
> /* sees zero and returns */
> ...
> snd_pcm_detach_substream(B);
> kfree(rt);
> wake_up(&rt->refcnt.waiter);
>
> Here rt is B's runtime. Since wait_event() can return on its initial
> condition check, could the final wake_up() access the embedded
> waitqueue after rt has been freed? A holds its own stream lock at
> this point, while B has already been unlinked.
Yes, and it's covered by another patch:
https://lore.kernel.org/20261015112256.3902-1-tiwai@suse.de
thanks,
Takashi
next prev parent reply other threads:[~2026-10-15 16:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 10:52 [PATCH v2] ALSA: pcm: Unlink substreams before releasing them Cen Zhang
2026-10-14 12:54 ` Takashi Iwai
2026-10-15 2:07 ` Cen Zhang
2026-10-15 7:17 ` Takashi Iwai
2026-10-15 15:19 ` Cen Zhang
2026-10-15 15:35 ` Cen Zhang
2026-10-15 16:19 ` Takashi Iwai [this message]
2026-10-15 16:28 ` Cen Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h5in6io5.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=baijiaju1990@gmail.com \
--cc=cassiogabrielcontato@gmail.com \
--cc=cezary.rojewski@intel.com \
--cc=jjzuming@gmail.com \
--cc=kees+treewide@kernel.org \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=phucduc.bui@gmail.com \
--cc=sammiee5311@gmail.com \
--cc=tglx@kernel.org \
--cc=thomas.weissschuh@linutronix.de \
--cc=tiwai@suse.com \
--cc=yilinzhang@moonshot.ai \
--cc=zzzccc427@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.