From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 303033876DD for ; Tue, 13 Jan 2026 10:16:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768299403; cv=none; b=A05nLSWYnAm20JTTWGl5furyx7+2UtpoVUQMWzdhFT0duVTPsT16pafzHOoa3uI1wA9swzksG2Qjd1gBBIVNS6ze+LY6azvnFAy9guOYZSmTnFshqZgg3DKBeAQJxTlmZNldPcTzoQpMhorivk9elqqNqWVC9HF4DujqzugoHFI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768299403; c=relaxed/simple; bh=O3OcpXya4at2AFvPrMPddlaCOZVWsMiBxyXzQVmbGIk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GN3hQsDVf7LVdHDF9ABXYJfolSbIENeih2ZhUJ6w+AmF7xbW9WexaWu5JCl0Cs0ZVS7RIxB2C8Wplu0xJyhw8ru5lBidTs6eHvqF5JV4jaFDswDB+TsBmwioNjro9VZFFsD44vtuYjNzzA9cungEriIq4MhN3djXlu0TssDEx5g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=UtbS42nf; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UtbS42nf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768299393; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vjsp2Pxh99kEipTyQ7GElGEt+SiIlC7dQ4lJqdrePlk=; b=UtbS42nfU8HGVh2RHG/ZNNI5ttViORhTlNMdGRQc9qpOvLnPjnqOMPyA2A4pVncuZj4zyN pIFWOAscryS9P+FqjKzeIjuovwKR+7q7qJaNrjUT2TjqRozg+xevnFzoDAvcJhjmDMhuiz nQJnnNcCrn1qnX8CK9xZSwJ7JgAgF+k= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-524-bLVTTVX1Pm2AONjrwC1DFw-1; Tue, 13 Jan 2026 05:16:27 -0500 X-MC-Unique: bLVTTVX1Pm2AONjrwC1DFw-1 X-Mimecast-MFC-AGG-ID: bLVTTVX1Pm2AONjrwC1DFw_1768299385 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A42C51956046; Tue, 13 Jan 2026 10:16:24 +0000 (UTC) Received: from localhost (unknown [10.72.112.148]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C3CB330001A2; Tue, 13 Jan 2026 10:16:22 +0000 (UTC) Date: Tue, 13 Jan 2026 18:16:18 +0800 From: Baoquan He To: Robin Murphy 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 Message-ID: References: <8ab8d8a620dee0109f33f5cb63d6bfeed35aac37.1768230104.git.robin.murphy@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8ab8d8a620dee0109f33f5cb63d6bfeed35aac37.1768230104.git.robin.murphy@arm.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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 > --- > 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 > >