Skip to content

Commit 3ee06a6

Browse files
geertuChristoph Hellwig
authored and
Christoph Hellwig
committed
dma-pool: fix too large DMA pools on medium memory size systems
On systems with at least 32 MiB, but less than 32 GiB of RAM, the DMA memory pools are much larger than intended (e.g. 2 MiB instead of 128 KiB on a 256 MiB system). Fix this by correcting the calculation of the number of GiBs of RAM in the system. Invert the order of the min/max operations, to keep on calculating in pages until the last step, which aids readability. Fixes: 1d65923 ("dma-pool: scale the default DMA coherent pool size with memory capacity") Signed-off-by: Geert Uytterhoeven <[email protected]> Acked-by: David Rientjes <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent abfbb29 commit 3ee06a6

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

kernel/dma/pool.c

+3-4
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,9 @@ static int __init dma_atomic_pool_init(void)
175175
* sizes to 128KB per 1GB of memory, min 128KB, max MAX_ORDER-1.
176176
*/
177177
if (!atomic_pool_size) {
178-
atomic_pool_size = max(totalram_pages() >> PAGE_SHIFT, 1UL) *
179-
SZ_128K;
180-
atomic_pool_size = min_t(size_t, atomic_pool_size,
181-
1 << (PAGE_SHIFT + MAX_ORDER-1));
178+
unsigned long pages = totalram_pages() / (SZ_1G / SZ_128K);
179+
pages = min_t(unsigned long, pages, MAX_ORDER_NR_PAGES);
180+
atomic_pool_size = max_t(size_t, pages << PAGE_SHIFT, SZ_128K);
182181
}
183182
INIT_WORK(&atomic_pool_work, atomic_pool_work_fn);
184183

0 commit comments

Comments
 (0)