ALSA: pcm: Create proc files only for non-empty preallocations
authorTakashi Iwai <tiwai@suse.de>
Tue, 5 Nov 2019 19:10:07 +0000 (20:10 +0100)
committerTakashi Iwai <tiwai@suse.de>
Wed, 6 Nov 2019 14:43:34 +0000 (15:43 +0100)
It makes little sense to create prealloc proc files for streams that
have the zero max size, which is a typical case for vmalloc buffers.
Skip the proc file creations to save resources in such a case.

Link: https://lore.kernel.org/r/20191105191007.18150-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/pcm_memory.c

index 19407f79b63808a6402976e94e158df7d14c062c..17ee361ce791ec784a69ffc1428537011a45945f 100644 (file)
@@ -203,7 +203,8 @@ static void snd_pcm_lib_preallocate_pages1(struct snd_pcm_substream *substream,
        if (substream->dma_buffer.bytes > 0)
                substream->buffer_bytes_max = substream->dma_buffer.bytes;
        substream->dma_max = max;
-       preallocate_info_init(substream);
+       if (max > 0)
+               preallocate_info_init(substream);
 }