[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <c846b1a2f43295cac926c7af2ce907f62baec518.1768230104.git.robin.murphy@arm.com>
Date: Mon, 12 Jan 2026 15:46:36 +0000
From: Robin Murphy <robin.murphy@....com>
To: m.szyprowski@...sung.com,
akpm@...ux-foundation.org,
vbabka@...e.cz,
david@...nel.org
Cc: bhe@...hat.com,
iommu@...ts.linux-foundation.org,
linux-mm@...ck.org,
vladimir.kondratiev@...ileye.com,
s-adivi@...com,
linux-kernel@...r.kernel.org,
lorenzo.stoakes@...cle.com,
Liam.Howlett@...cle.com,
rppt@...nel.org,
surenb@...gle.com,
mhocko@...e.com,
jackmanb@...gle.com,
hannes@...xchg.org,
ziy@...dia.com
Subject: [PATCH 1/3] dma/pool: Improve pool lookup
If CONFIG_ZONE_DMA32 is enabled, but we have not allocated the
corresponding atomic_pool_dma32, dma_guess_pool() may return the NULL
value of that and fail a GFP_DMA32 allocation without trying to fall
back to other pools which may exist. Furthermore, if no GFP_DMA pool
exists, it is preferable to try GFP_DMA32 rather than immediately fall
back to GFP_KERNEL with even less chance of success. Improve matters
by encoding an explicit order of pool preference for each flag.
Signed-off-by: Robin Murphy <robin.murphy@....com>
---
kernel/dma/pool.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/kernel/dma/pool.c b/kernel/dma/pool.c
index 26392badc36b..2645cfb5718b 100644
--- a/kernel/dma/pool.c
+++ b/kernel/dma/pool.c
@@ -224,10 +224,10 @@ postcore_initcall(dma_atomic_pool_init);
static inline struct gen_pool *dma_guess_pool(struct gen_pool *prev, gfp_t gfp)
{
if (prev == NULL) {
- if (IS_ENABLED(CONFIG_ZONE_DMA32) && (gfp & GFP_DMA32))
- return atomic_pool_dma32;
- if (atomic_pool_dma && (gfp & GFP_DMA))
- return atomic_pool_dma;
+ if (gfp & GFP_DMA)
+ return atomic_pool_dma ?: atomic_pool_dma32 ?: atomic_pool_kernel;
+ if (gfp & GFP_DMA32)
+ return atomic_pool_dma32 ?: atomic_pool_dma ?: atomic_pool_kernel;
return atomic_pool_kernel;
}
if (prev == atomic_pool_kernel)
--
2.34.1
Powered by blists - more mailing lists