summaryrefslogtreecommitdiff
path: root/sound/usb
diff options
context:
space:
mode:
authorChanho Min <chanho.min@lge.com>2018-11-26 08:36:37 +0300
committerTakashi Iwai <tiwai@suse.de>2018-11-29 10:15:19 +0300
commitb888a5f713e4d17faaaff24316585a4eb07f35b7 (patch)
tree81c22c24ded0fd8da2d813aa6c0eee4c6f0c0cd3 /sound/usb
parentb51abed8355e5556886623b2772fa6b7598d2282 (diff)
downloadlinux-b888a5f713e4d17faaaff24316585a4eb07f35b7.tar.xz
ALSA: pcm: Fix starvation on down_write_nonblock()
Commit 67ec1072b053 ("ALSA: pcm: Fix rwsem deadlock for non-atomic PCM stream") fixes deadlock for non-atomic PCM stream. But, This patch causes antother stuck. If writer is RT thread and reader is a normal thread, the reader thread will be difficult to get scheduled. It may not give chance to release readlocks and writer gets stuck for a long time if they are pinned to single cpu. The deadlock described in the previous commit is because the linux rwsem queues like a FIFO. So, we might need non-FIFO writelock, not non-block one. My suggestion is that the writer gives reader a chance to be scheduled by using the minimum msleep() instaed of spinning without blocking by writer. Also, The *_nonblock may be changed to *_nonfifo appropriately to this concept. In terms of performance, when trylock is failed, this minimum periodic msleep will have the same performance as the tick-based schedule()/wake_up_q(). [ Although this has a fairly high performance penalty, the relevant code path became already rare due to the previous commit ("ALSA: pcm: Call snd_pcm_unlink() conditionally at closing"). That is, now this unconditional msleep appears only when using linked streams, and this must be a rare case. So we accept this as a quick workaround until finding a more suitable one -- tiwai ] Fixes: 67ec1072b053 ("ALSA: pcm: Fix rwsem deadlock for non-atomic PCM stream") Suggested-by: Wonmin Jung <wonmin.jung@lge.com> Signed-off-by: Chanho Min <chanho.min@lge.com> Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
0 files changed, 0 insertions, 0 deletions