lkml.org 
[lkml]   [2023]   [Jun]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [BUG] ALSA: core: pcm_memory: a possible data race in do_alloc_pages()
From
On 26. 06. 23 9:33, Takashi Iwai wrote:
> On Mon, 26 Jun 2023 09:31:18 +0200,
> Tuo Li wrote:
>>
>>
>> Hello,
>>
>> Thank you for your reply!
>
> FWIW, the simplest fix would be something like below, just extending
> the mutex coverage. But it'll serialize the all calls, so it might
> influence on the performance, while it's the safest way.

It may be better to update total_pcm_alloc_bytes before
snd_dma_alloc_dir_pages() call and decrease this value when allocation fails
to allow parallel allocations. Then the mutex can be held only for the
total_pcm_alloc_bytes variable update.

Eventually, total_pcm_alloc_bytes may be atomic.

Jaroslav

--
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

\
 
 \ /
  Last update: 2023-06-26 09:58    [W:0.047 / U:0.104 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site