* [PATCH] swiotlb: Do not try to allocate a TLB bigger than MAX_ORDER pages
@ 2023-10-25 8:44 Petr Tesarik
2023-10-25 14:27 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Petr Tesarik @ 2023-10-25 8:44 UTC (permalink / raw)
To: Christoph Hellwig, Marek Szyprowski, Robin Murphy, Petr Tesarik,
open list:DMA MAPPING HELPERS, open list
Cc: Wangkefeng, Roberto Sassu, petr, Ben Greear
From: Petr Tesarik <petr.tesarik1@huawei-partners.com>
When allocating a new pool at runtime, reduce the number of slabs so that
the allocation order is at most MAX_ORDER. This avoids a kernel WARNING in
__alloc_pages().
The warning is relatively benign, because the pool size is subsequently
reduced when allocation fails, but it is silly to start with a request that
is known to fail, especially since this is the default behavior if the
kernel is built with CONFIG_SWIOTLB_DYNAMIC=y and booted without any
swiotlb= parameter.
Reported-by: Ben Greear <greearb@candelatech.com>
Closes: https://lore.kernel.org/netdev/4f173dd2-324a-0240-ff8d-abf5c191be18@candelatech.com/
Fixes: 1aaa736815eb ("swiotlb: allocate a new memory pool when existing pools are full")
Signed-off-by: Petr Tesarik <petr.tesarik1@huawei-partners.com>
---
kernel/dma/swiotlb.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
index 01637677736f..dff067bd56b1 100644
--- a/kernel/dma/swiotlb.c
+++ b/kernel/dma/swiotlb.c
@@ -678,6 +678,11 @@ static struct io_tlb_pool *swiotlb_alloc_pool(struct device *dev,
size_t pool_size;
size_t tlb_size;
+ if (nslabs > SLABS_PER_PAGE << MAX_ORDER) {
+ nslabs = SLABS_PER_PAGE << MAX_ORDER;
+ nareas = limit_nareas(nareas, nslabs);
+ }
+
pool_size = sizeof(*pool) + array_size(sizeof(*pool->areas), nareas);
pool = kzalloc(pool_size, gfp);
if (!pool)
--
2.42.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] swiotlb: Do not try to allocate a TLB bigger than MAX_ORDER pages
2023-10-25 8:44 [PATCH] swiotlb: Do not try to allocate a TLB bigger than MAX_ORDER pages Petr Tesarik
@ 2023-10-25 14:27 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2023-10-25 14:27 UTC (permalink / raw)
To: Petr Tesarik
Cc: Christoph Hellwig, Marek Szyprowski, Robin Murphy, Petr Tesarik,
open list:DMA MAPPING HELPERS, open list, Wangkefeng,
Roberto Sassu, petr, Ben Greear
Thanks,
applied to the dma-mapping tree for Linux 6.6.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-10-25 14:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-25 8:44 [PATCH] swiotlb: Do not try to allocate a TLB bigger than MAX_ORDER pages Petr Tesarik
2023-10-25 14:27 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox