Re: [PATCH] ASoC: SOF: Use high-priority workqueue for PCM period elapsed

Pierre-Louis Bossart <[email protected]> Fri, 31 Jul 2026 11:20:08 +0200
Newsgroups org.kernel.vger.linux-sound
Message-ID <[email protected]>
On 7/30/26 15:04, Peter Ujfalusi wrote:
> From: Yu-Hsuan Hsu <[email protected]>
> 
> The snd_sof_pcm_period_elapsed function currently schedules work on the
> system-wide workqueue. This can lead to potential delays or jitter in
> audio processing if the system workqueue is busy with other tasks.
> 
> To improve real-time performance and ensure timely processing of PCM
> periods, we can use the system_highpri_wq instead of the default work
> queue.
> 
> In performance testing, this change significantly reduced the observed
> scheduling delays. For instance, under load(stressapptest -M 15000 -m
> 60), the maximum delay dropped from 9ms on the system workqueue to 5ms
> on the dedicated high-priority workqueue.
> 
> Suggested-by: Kai Vehmanen <[email protected]>
> Signed-off-by: Yu-Hsuan Hsu <[email protected]>
> Reviewed-by: Péter Ujfalusi <[email protected]>
> Reviewed-by: Kai Vehmanen <[email protected]>
> Reviewed-by: Bard Liao <[email protected]>
> Signed-off-by: Peter Ujfalusi <[email protected]>

Sounds good but should this higher priority queue be used for other
things as well?

e.g.

period-elapsed for compressed streams:
schedule_work(&spcm->stream[cstream->direction].period_elapsed_work);

and the SoundWire interrupt handling with additional workqueues:
schedule_work(&amd_manager->amd_sdw_irq_thread);
schedule_work(&amd_manager->amd_sdw_work);
schedule_work(&cdns->work);

Not sure what the rules are to define what's high-priority and what's
not... It could be that different systems have different requirements...

> ---
>  sound/soc/sof/pcm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c
> index b2071edeaea6..f748d072109a 100644
> --- a/sound/soc/sof/pcm.c
> +++ b/sound/soc/sof/pcm.c
> @@ -62,7 +62,7 @@ void snd_sof_pcm_period_elapsed(struct snd_pcm_substream *substream)
>  	 * To avoid sending IPC before the previous IPC is handled, we
>  	 * schedule delayed work here to call the snd_pcm_period_elapsed().
>  	 */
> -	schedule_work(&spcm->stream[substream->stream].period_elapsed_work);
> +	queue_work(system_highpri_wq, &spcm->stream[substream->stream].period_elapsed_work);
>  }
>  EXPORT_SYMBOL(snd_sof_pcm_period_elapsed);
>