Page MenuHomeFreeBSD

sound: Do not access cv_waiters
ClosedPublic

Authored by christos on Nov 27 2024, 3:32 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Jan 14, 2:06 AM
Unknown Object (File)
Sat, Jan 11, 11:50 AM
Unknown Object (File)
Sat, Jan 11, 1:07 AM
Unknown Object (File)
Sun, Jan 5, 9:56 AM
Unknown Object (File)
Fri, Jan 3, 6:32 AM
Unknown Object (File)
Dec 28 2024, 6:41 PM
Unknown Object (File)
Dec 28 2024, 8:12 AM
Unknown Object (File)
Dec 27 2024, 11:36 AM
Subscribers

Details

Summary

Remove uses of cv_waiters in PCM_RELEASE and CHN_BROADCAST, and also use
a counter around cv_timedwait_sig() in chn_sleep(), which is checked in
pcm_killchans(), as opposed to reading cv_waiters directly, which is a
layering violation.

While here, move CHN_BROADCAST below the channel lock operations.

Reported by: avg, jhb, markj
Sponsored by: The FreeBSD Foundation
MFC after: 2 days

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

christos retitled this revision from sound: Do not access cv_waiters directly to sound: Do not access cv_waiters.
christos edited the summary of this revision. (Show Details)
christos added reviewers: avg, dev_submerge.ch.

Do not use cv_waiters at all.

Looks goof to me.
Thank you!

This revision is now accepted and ready to land.Nov 27 2024, 6:11 PM
sys/dev/sound/pcm/sound.c
224–225

From a quick look, this appears to be an optimization.
But I can be wrong about that.
Would anything break or hurt user experience if this fast path was removed?

sys/dev/sound/pcm/sound.c
224–225

I cannot give you answer in concrete numbers as I haven't benchmarked this specific path. The reason I have added this check is to not issue redundant calls to chn_shutdown() and chn_flush()/chn_abort() if the channel is already completely stopped. With large numbers of channels removing this check could potentially hurt performance I guess.

Why do you think it should be removed?

sys/dev/sound/pcm/sound.c
224–225

I was just wondering.

sys/dev/sound/pcm/sound.c
224–225

Also this is an easy way to tell if we need to re-try stopping the channels (see how again is used), so there has to be some kind of check IMHO anyway.

sys/dev/sound/pcm/channel.h
120

Since there are two CVs in this structure, it'd be more useful to say which one this counter applies to.

christos added inline comments.
sys/dev/sound/pcm/channel.h
120

chn_sleep() always calls cv_timedwait_sig() on intr_cv though.

This revision was automatically updated to reflect the committed changes.