Skip to contentSkip to conversation

dma/pool: eliminate CMA alloc warning in atomic_pool_expand

PATCH Applied Maximilian Heyne 2 participants 2 messages Oct 30 – Nov 3

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dma/pool: eliminate CMA alloc warning in atomic_pool_expand

atomic_pool_expand() allocates with decreasing page order first from the CMA and if that fails via alloc_pages(). If the cma allocation fails a warning, such as the following, is printed:

cma: __cma_alloc_frozen: reserved: alloc failed, req-size: 4096 pages, ret: -16
cma: number of available pages:
cma: range 0: 1024@0
cma:
=> 1024 free of 1024 total pages
DMA: preallocated 262144 KiB GFP_KERNEL pool for atomic allocations

In this case the allocation succeeded via alloc_pages and therefore, printing the warning is not necessary. Therefore, similar to commit 463d439becb8 ("dma/pool: eliminate alloc_pages warning in atomic_pool_expand") silence the warning also for the CMA attempt.

Fixes d7e673ec2c8e ("dma-pool: Only allocate from CMA when in same memory zone")
---
 kernel/dma/pool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/dma/pool.c +1 -1
index 00f422a1e8966..aa44fd74db538 100644
@@ -99,7 +99,7 @@ static int atomic_pool_expand(struct dma_gen_pool *dma_pool, size_t pool_size,
 		pool_size = 1 << (PAGE_SHIFT + order);
 		if (cma_in_zone(gfp))
 			page = dma_alloc_from_contiguous(NULL, 1 << order,
-							 order, false);
+							 order, true);
 		if (!page)
 			page = alloc_pages(gfp | __GFP_NOWARN, order);
 	} while (!page && order-- > 0);
Signature · 1 line
2.50.1
maintainer Applied
#1 lore raw
Quoted 11 lines · Maximilian Heyne

atomic_pool_expand() allocates with decreasing page order first from the CMA and if that fails via alloc_pages(). If the cma allocation fails a warning, such as the following, is printed:

cma: __cma_alloc_frozen: reserved: alloc failed, req-size: 4096 pages, ret: -16
cma: number of available pages:
cma: range 0: 1024@0
cma:
=> 1024 free of 1024 total pages
DMA: preallocated 262144 KiB GFP_KERNEL pool for atomic allocations

Quoted 7 lines

In this case the allocation succeeded via alloc_pages and therefore, printing the warning is not necessary. Therefore, similar to commit 463d439becb8 ("dma/pool: eliminate alloc_pages warning in atomic_pool_expand") silence the warning also for the CMA attempt.

Fixes d7e673ec2c8e ("dma-pool: Only allocate from CMA when in same memory zone")

Applied to dma-mapping-for-next. Thanks!

Best regards

Signature · 2 lines
Marek Szyprowski, PhD
Samsung R&D Institute Poland