ALSA: pcm: Yet finer pending signal check in OSS read/write loop
PATCH 1/2 ALSA: pcm: Yet finer pending signal check in OSS read/write loop
PCM OSS emulation has the nested inner loops, and the loops in snd_pcm_oss_read3() and write3() have no pending signal check, so potentially they can hog for too long time for processing. Add the extra check there.
While we're at it, a slight code cleanup using the standard macro for the PCM state check is used.
--- sound/core/oss/pcm_oss.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
sound/core/oss/pcm_oss.c +7 -5
@@ -1221,8 +1221,7 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, conststruct snd_pcm_runtime *runtime = substream->runtime;int ret;while (1 ) { -if (runtime->status->state ==SNDRV_PCM_STATE_XRUN || - runtime->status->state ==SNDRV_PCM_STATE_SUSPENDED ) { +if (!snd_pcm_running (substream)) {#ifdef OSS_DEBUG pcm_dbg(substream->pcm, "pcm_oss: write: recovering from %s\n",
@@ -1241,6 +1240,8 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const/* has not been started */ if (runtime->status->state ==SNDRV_PCM_STATE_PREPARED )return -EAGAIN ; +if (signal_pending (current)) +return -ERESTARTSYS ; }return ret; }
@@ -1278,10 +1279,11 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *pif (ret <0 )break ; } -continue ; - } -if (ret != -ESTRPIPE ) + }else if (ret != -ESTRPIPE ) {break ; + } +if (signal_pending (current)) +return -ERESTARTSYS ; }return ret; }
Signature · 1 line
2.16.3
PATCH 2/2 ALSA: pcm: Add cond_resched() in OSS read/write loop
The PCM OSS read/write loops may take too long occasionally when a huge size of data is given. Add cond_resched() to become more system- friendlier.
--- sound/core/oss/pcm_oss.c | 2 ++ 1 file changed, 2 insertions(+)
sound/core/oss/pcm_oss.c +2 -0
@@ -1452,6 +1452,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const chabreak ; } tmp =0 ; +cond_resched (); }atomic_dec (&runtime->oss.rw_ref);return xfer >0 ? (snd_pcm_sframes_t )xfer : tmp;
@@ -1547,6 +1548,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __usebreak ; } tmp =0 ; +cond_resched (); }atomic_dec (&runtime->oss.rw_ref);return xfer >0 ? (snd_pcm_sframes_t )xfer : tmp;
Signature · 1 line
2.16.3
Quoted 10 lines · Takashi Iwai
PCM OSS emulation has the nested inner loops, and the loops in
snd_pcm_oss_read3()andwrite3()have no pending signal check, so potentially they can hog for too long time for processing. Add the extra check there.While we're at it, a slight code cleanup using the standard macro for the PCM state check is used.
Signed-off-by Takashi Iwai <[email protected]>
Scratch these two patches. Both are superfluous, not really fix anything substantial.
Sorry for the noise.
Takashi