[alsa-devel] [PATCH 1/2] ALSA: pcm: Set per-card upper limit of PCM buffer allocations
Takashi Iwai
tiwai at suse.de
Tue Jan 21 07:13:22 CET 2020
On Tue, 21 Jan 2020 03:13:20 +0100,
Keyon Jie wrote:
>
>
>
> On 2020/1/20 下午8:44, Takashi Iwai wrote:
> > Currently, the available buffer allocation size for a PCM stream
> > depends on the preallocated size; when a buffer has been preallocated,
> > the max buffer size is set to that size, so that application won't
> > re-allocate too much memory. OTOH, when no preallocation is done,
> > each substream may allocate arbitrary size of buffers as long as
> > snd_pcm_hardware.buffer_bytes_max allows -- which can be quite high,
> > HD-audio sets 1GB there.
> >
> > It means that the system may consume a high amount of pages for PCM
> > buffers, and they are pinned and never swapped out. This can lead to
> > OOM easily.
> >
> > For avoiding such a situation, this patch adds the upper limit per
> > card. Each snd_pcm_lib_malloc_pages() and _free_pages() calls are
> > tracked and it will return an error if the total amount of buffers
> > goes over the defined upper limit. The default value is set to 32MB,
>
> Is this typo here? In the patch, "max_alloc_per_card = 32UL * 1024UL *
> 1024UL * 1024UL", should be 32GB?
Oh yes, it's an obvious typo. Fixed now.
Thanks!
Takashi
More information about the Alsa-devel
mailing list