From: Baoquan He <bhe@redhat.com>
To: Robin Murphy <robin.murphy@arm.com>
Cc: m.szyprowski@samsung.com, akpm@linux-foundation.org,
vbabka@suse.cz, david@kernel.org,
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: Re: [PATCH 3/3] dma/pool: Avoid allocating redundant pools
Date: Tue, 13 Jan 2026 18:16:18 +0800 [thread overview]
Message-ID: <aWYbcnglF5P/WhL4@MiWiFi-R3L-srv> (raw)
In-Reply-To: <8ab8d8a620dee0109f33f5cb63d6bfeed35aac37.1768230104.git.robin.murphy@arm.com>
On 01/12/26 at 03:46pm, Robin Murphy wrote:
> On smaller systems, e.g. embedded arm64, it is common for all memory
> to end up in ZONE_DMA32 or even ZONE_DMA. In such cases it is redundant
This is true and the whole series looks great to me. Do we need adjust
warn_alloc() to handle empty DMA32 zone too like empty DMA zone case?
> to allocate a nominal pool for an empty higher zone that just ends up
> coming from a lower zone that should already have its own pool anyway.
> We already have logic to skip allocating a ZONE_DMA pool when that is
> empty, so generalise that to save memory in the case of other zones too.
>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
> kernel/dma/pool.c | 19 ++++++++++++++-----
> 1 file changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/dma/pool.c b/kernel/dma/pool.c
> index 2645cfb5718b..c5da29ad010c 100644
> --- a/kernel/dma/pool.c
> +++ b/kernel/dma/pool.c
> @@ -184,6 +184,12 @@ static __init struct gen_pool *__dma_atomic_pool_init(size_t pool_size,
> return pool;
> }
>
> +#ifdef CONFIG_ZONE_DMA32
> +#define has_managed_dma32 has_managed_zone(ZONE_DMA32)
> +#else
> +#define has_managed_dma32 false
> +#endif
> +
> static int __init dma_atomic_pool_init(void)
> {
> int ret = 0;
> @@ -199,17 +205,20 @@ static int __init dma_atomic_pool_init(void)
> }
> INIT_WORK(&atomic_pool_work, atomic_pool_work_fn);
>
> - atomic_pool_kernel = __dma_atomic_pool_init(atomic_pool_size,
> + /* All memory might be in the DMA zone(s) to begin with */
> + if (has_managed_zone(ZONE_NORMAL)) {
> + atomic_pool_kernel = __dma_atomic_pool_init(atomic_pool_size,
> GFP_KERNEL);
> - if (!atomic_pool_kernel)
> - ret = -ENOMEM;
> + if (!atomic_pool_kernel)
> + ret = -ENOMEM;
> + }
> if (has_managed_dma()) {
> atomic_pool_dma = __dma_atomic_pool_init(atomic_pool_size,
> GFP_KERNEL | GFP_DMA);
> if (!atomic_pool_dma)
> ret = -ENOMEM;
> }
> - if (IS_ENABLED(CONFIG_ZONE_DMA32)) {
> + if (has_managed_dma32) {
> atomic_pool_dma32 = __dma_atomic_pool_init(atomic_pool_size,
> GFP_KERNEL | GFP_DMA32);
> if (!atomic_pool_dma32)
> @@ -228,7 +237,7 @@ static inline struct gen_pool *dma_guess_pool(struct gen_pool *prev, gfp_t gfp)
> 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;
> + return atomic_pool_kernel ?: atomic_pool_dma32 ?: atomic_pool_dma;
> }
> if (prev == atomic_pool_kernel)
> return atomic_pool_dma32 ? atomic_pool_dma32 : atomic_pool_dma;
> --
> 2.34.1
>
>
next prev parent reply other threads:[~2026-01-13 10:16 UTC|newest]
Thread overview: 8+ 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 ` [PATCH 1/3] dma/pool: Improve pool lookup Robin Murphy
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
2026-01-13 10:16 ` Baoquan He [this message]
2026-01-13 16:14 ` Robin Murphy
2026-01-13 14:07 ` [PATCH 0/3] dma-mapping: Improve atomic pool behaviour Vladimir Kondratiev
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=aWYbcnglF5P/WhL4@MiWiFi-R3L-srv \
--to=bhe@redhat.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--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=robin.murphy@arm.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