Skip to content

Commit

Permalink
ALSA: memalloc: use __GFP_RETRY_MAYFAIL in snd_malloc_dev_pages()
Browse files Browse the repository at this point in the history
Use __GFP_RETRY_MAYFAIL instead of __GFP__NORETRY in
snd_malloc_dev_pages() to allocate pages for device memory.
The MAYFAIL flag retains the semantics of not triggering the OOM killer,
but lowers the risk of alloc failure.

This change addresses recurring failures with SOF audio driver in test
cases where a system suspend stress test is run combined with a high
memory-load use-case. The failure typically shows up as:

[ 379.480229] sof-audio-pci-intel-tgl 0000:00:1f.3: booting DSP firmware
[ 379.484803] sof-audio-pci-intel-tgl 0000:00:1f.3: error: memory alloc failed: -12
[ 379.484810] sof-audio-pci-intel-tgl 0000:00:1f.3: error: dma prepare for ICCMAX stream failed

Debug on these systems has shown that even a single page alloc
fails with __GFP_NORETRY in this case. However, while under significant
load on physical memory, the system does have lots of reclaimable
pages available, so with __GFP_RETRY_MAYFAIL, the issue is not hit.

The error is fairly severe as audio capability is completely lost
at system resume, so seems that RETRY_MAYFAIL is a better default
approach to use here.

BugLink: thesofproject#3844
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
  • Loading branch information
kv2019i committed Sep 22, 2022
1 parent 99c2dfe commit 09ce62e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sound/core/memalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static void snd_malloc_dev_pages(struct snd_dma_buffer *dmab, size_t size)

gfp_flags = GFP_KERNEL
| __GFP_COMP /* compound page lets parts be mapped */
| __GFP_NORETRY /* don't trigger OOM-killer */
| __GFP_RETRY_MAYFAIL /* don't trigger OOM-killer */
| __GFP_NOWARN; /* no stack trace print - this call is non-critical */
dmab->area = dma_alloc_coherent(dmab->dev.dev, size, &dmab->addr,
gfp_flags);
Expand Down

0 comments on commit 09ce62e

Please sign in to comment.