linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: m.szyprowski@samsung.com, akpm@linux-foundation.org,
	vbabka@suse.cz, david@kernel.org
Cc: bhe@redhat.com, iommu@lists.linux-foundation.org,
	linux-mm@kvack.org, vladimir.kondratiev@mobileye.com,
	s-adivi@ti.com, linux-kernel@vger.kernel.org,
	lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com,
	rppt@kernel.org, surenb@google.com, mhocko@suse.com,
	jackmanb@google.com, hannes@cmpxchg.org, ziy@nvidia.com
Subject: [PATCH 1/3] dma/pool: Improve pool lookup
Date: Mon, 12 Jan 2026 15:46:36 +0000	[thread overview]
Message-ID: <c846b1a2f43295cac926c7af2ce907f62baec518.1768230104.git.robin.murphy@arm.com> (raw)
In-Reply-To: <cover.1768230104.git.robin.murphy@arm.com>

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@arm.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



  reply	other threads:[~2026-01-12 15:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-12 15:46 [PATCH 0/3] dma-mapping: Improve atomic pool behaviour Robin Murphy
2026-01-12 15:46 ` Robin Murphy [this message]
2026-01-12 15:46 ` [PATCH 2/3] mm_zone: Generalise has_managed_dma() Robin Murphy
2026-01-12 19:32   ` David Hildenbrand (Red Hat)
2026-01-12 15:46 ` [PATCH 3/3] dma/pool: Avoid allocating redundant pools Robin Murphy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c846b1a2f43295cac926c7af2ce907f62baec518.1768230104.git.robin.murphy@arm.com \
    --to=robin.murphy@arm.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=bhe@redhat.com \
    --cc=david@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jackmanb@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=m.szyprowski@samsung.com \
    --cc=mhocko@suse.com \
    --cc=rppt@kernel.org \
    --cc=s-adivi@ti.com \
    --cc=surenb@google.com \
    --cc=vbabka@suse.cz \
    --cc=vladimir.kondratiev@mobileye.com \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox