Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: "David Hildenbrand (Arm)" <david@kernel.org>,
	Feng Tang <feng.tang@linux.alibaba.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>,
	Ying Huang <ying.huang@linux.alibaba.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Lorenzo Stoakes <ljs@kernel.org>,
	Liam.Howlett@oracle.com, Vlastimil Babka <vbabka@kernel.org>,
	Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>,
	linux-mm@kvack.org, Christoph Hellwig <hch@lst.de>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
	Changrong Chen <chenchangrong.ccr@alibaba-inc.com>
Subject: Re: [PATCH v3] dma-contiguous: setup default numa cma area if not configured explicitly
Date: Fri, 8 May 2026 13:58:41 +0100	[thread overview]
Message-ID: <59d05fdb-bb61-4d92-8df3-45aa3f9f7bee@arm.com> (raw)
In-Reply-To: <a5660e22-b1f9-4dcb-a190-f3dc5253c570@kernel.org>

On 2026-05-08 12:46 pm, David Hildenbrand (Arm) wrote:
> On 5/6/26 17:46, Feng Tang wrote:
>> On Fri, May 01, 2026 at 08:51:39PM +0200, David Hildenbrand (Arm) wrote:
>>> On 4/28/26 10:37, Feng Tang wrote:
>>>> Hi David,
>>>
>>> Hi!
>>>
>>> [...]
>>>
>>>>
>>>> Right for default kernel configs.
>>>>
>>>> In kernel/dma/Kconfig:
>>>>
>>>> config CMA_SIZE_MBYTES
>>>> 	int "Size in Mega Bytes"
>>>> 	depends on !CMA_SIZE_SEL_PERCENTAGE
>>>> 	default 0 if X86
>>>> 	default 16
>>>>
>>>> config CMA_SIZE_PERCENTAGE
>>>> 	int "Percentage of total memory"
>>>> 	depends on !CMA_SIZE_SEL_MBYTES
>>>> 	default 0 if X86
>>>> 	default 10
>>>>
>>>>
>>>> Yes. I thought about that, and didn't have good solution, and used this
>>>> given it's on a multi-numa-node machine, which may not be too bad
>>>> regarding memory usage.
>>>
>>> It sounds wrong given the existing config options.
>>
>> Yes, it is confusing.
>>
>>>>
>>>> Robin did concern about the memory usage for embedded/small devices in
>>>> v2 review, and we change to v3 to not affect them.
>>>>
>>>>
>>>> I agree :)
>>>>
>>>>   
>>>> This sounds good to me, if no objection from others. Maybe default 64MB
>>>> or more. One good part is, all these setup is under protection of
>>>> CONFIG_DMA_NUMA_CMA.
>>>
>>> I cannot do the heavy thinking here because -EBUSY, but maybe you want a config
>>> option similar to CMA_SIZE_MBYTES/CMA_SIZE_PERCENTAGE that either controls that
>>> these sizes will be split over NUMA nodes, or another one, that sets the default
>>> for pernuma.
>>
>> Maybe a CMA_NUMA_SIZE_MBYTES?
> 
> Maybe, I'm hoping some CMA DMA people have the capacity to provide input.

But really that _is_ pretty much the idea here - we're effecting a 
kernel-level default "pernuma" value, which just happens to also be 
CMA_SIZE_*. But in the process we also need to tweak the "pernuma" 
behaviour itself to work as a default, since quietly forcing the current 
opt-in behaviour on single node systems could only hurt them - multiple 
default CMA areas on the same node offers no performance benefit, while 
reducing non-movable allocation capacity which could well be detrimental.

Indeed I am rather assuming that actual NUMA systems should have enough 
memory that this isn't a big deal, but I don't believe that's 
particularly unreasonable. End users should still be able to override 
with "numa_cma=0:0" if they don't want it, the only potential gap is if 
distros want to ship kernels with DMA_NUMA_CMA enabled for command-line 
opt-in but _without_ this new default behaviour. For that we could 
perhaps add something like:

config CMA_SIZE_PERNUMA
	bool "Default CMA area per NUMA node"
	depends on DMA_NUMA_CMA
	default y
	help
	  On systems with more than one NUMA node, the selected CMA
	  area size will be also allocated on each additional node,
	  so that most devices may have benefit from better DMA
	  locality without an explicit command-line opt-in.

Thanks,
Robin.

> 
>>   
>>> [...]
>>>
>>>>
>>>> My thought was 'struct cma' already have 'nid' member, and when CONFIG_NUMA=y,
>>>> it may be useful to save the 'nid' info instead of NUMA_NO_NODE for the default
>>>> cma area (cmdline like cma=XXG@YYG could make it on different node)
>>>
>>> Ah, yeah. It's a bit nasty that we have to handle the default area like that.
>>>
>>> Another sign that we probably shouldn't deal with the default area :)
>>
>> Yep, in v2 I didn't touch the default area, while Robin had a concern
>> that the v2 approach will bindly add an extra per-numa cma area for
>> the node which already has the default area, which will hurt those
>> small/embedded devices which has limited number of memory. Adding
>> the nid check is trying to keep the behavior of one node device
>> unchanged.
>>
>>>>
>>>>
>>>> Per my understanding, it won't. There is a cma_validate_zones() to prevent it
>>>> from crossing zones.
>>>
>>> It's a bit confusing, because it ignores other nids.
>>
>> I might have missed your point. Do you mean one cma are could have
>> multiple ranges?
> 
> I don't know, it's confusing :)
> 



  reply	other threads:[~2026-05-08 12:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-28  6:05 [PATCH v3] dma-contiguous: setup default numa cma area if not configured explicitly Feng Tang
2026-04-28  7:52 ` David Hildenbrand (Arm)
2026-04-28  8:37   ` Feng Tang
2026-04-28  9:03     ` Feng Tang
2026-05-01 18:51     ` David Hildenbrand (Arm)
2026-05-06 15:46       ` Feng Tang
2026-05-08 11:46         ` David Hildenbrand (Arm)
2026-05-08 12:58           ` Robin Murphy [this message]
2026-05-08 20:57             ` David Hildenbrand (Arm)
2026-05-01  5:57 ` kernel test robot

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=59d05fdb-bb61-4d92-8df3-45aa3f9f7bee@arm.com \
    --to=robin.murphy@arm.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=catalin.marinas@arm.com \
    --cc=chenchangrong.ccr@alibaba-inc.com \
    --cc=david@kernel.org \
    --cc=feng.tang@linux.alibaba.com \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=mhocko@suse.com \
    --cc=rppt@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    --cc=will@kernel.org \
    --cc=ying.huang@linux.alibaba.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