Page MenuHomeFreeBSD

sound: Do not access cv_waiters
ClosedPublic

Authored by christos on Wed, Nov 27, 3:32 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Dec 16, 10:11 PM
Unknown Object (File)
Mon, Dec 16, 4:22 AM
Unknown Object (File)
Wed, Dec 11, 12:01 AM
Unknown Object (File)
Sat, Dec 7, 4:11 AM
Unknown Object (File)
Wed, Dec 4, 10:23 AM
Unknown Object (File)
Wed, Dec 4, 4:52 AM
Unknown Object (File)
Mon, Dec 2, 2:59 AM
Unknown Object (File)
Wed, Nov 27, 3:42 PM
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 Skipped
Unit
Tests Skipped
Build Status
Buildable 60840
Build 57724: arc lint + arc unit

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.Wed, Nov 27, 6:11 PM
sys/dev/sound/pcm/sound.c
224

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

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

I was just wondering.

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

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.