* Re: [PATCH v3] dma-contiguous: setup default numa cma area if not configured explicitly
[not found] ` <f900172c-341a-4956-b7b7-b297418be913@kernel.org>
@ 2026-05-06 15:46 ` Feng Tang
2026-05-08 11:46 ` David Hildenbrand (Arm)
0 siblings, 1 reply; 4+ messages in thread
From: Feng Tang @ 2026-05-06 15:46 UTC (permalink / raw)
To: David Hildenbrand (Arm)
Cc: Marek Szyprowski, Robin Murphy, Ying Huang, Andrew Morton,
Lorenzo Stoakes, Liam.Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, linux-mm, Christoph Hellwig,
Catalin Marinas, Will Deacon, iommu, linux-kernel, Changrong Chen
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!
>
> [...]
>
> >>
> >> Okay, so on x86 it is not silent, because they don't even have a default CMA area?
> >
> > 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
> >
> >>>
> >>> One thought is to follow the current cma reserving policy for platform
> >>> with 'CONFIG_DMA_NUMA_CMA=y', that if the numa cma (either the 'numa cma'
> >>> or 'cma pernuma' method) is not explicitly configured, set it up
> >>> according to size of default 'dma_contiguous_default_area', while
> >>> skipping the numa node where the 'dma_contiguous_default_area' lies
> >>> in, this way the default behavior of platform with one NUMA node is
> >>> kept unchanged.
> >>
> >> So, the kernel is configured to have a certain CONFIG_CMA_SIZE_MBYTES size, but
> >> you go ahead and multiply that by the number of nodes? Sounds wrong.
> >
> > 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.
> >
> >>
> >> The whole proposal here looks rather hacky.
> >
> > I agree :)
> >
> >> Wouldn't a default for e.g., pernuma_size_bytes make more sense, that users can
> >> then overwrite on the cmdline?
> >
> > 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?
> [...]
>
> >>> +extern int cma_get_nid(const struct cma *cma)
> >>> +{
> >>> + return cma->nid;
> >>> +}
> >>
> >> Why do you have to store the nid instead of just looking it up from the base_pfn
> >> in here?
> >
> > 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.
> >
> >>
> >> Also, what is the expectation when the ranges would span different NIDs? (is
> >> that possible?)
> >
> > 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? IIUC, the default cma area could have only one range
which was covered by this check, while hugetlb_cma could have multiple
ranges.
Thanks,
Feng
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] dma-contiguous: setup default numa cma area if not configured explicitly
2026-05-06 15:46 ` [PATCH v3] dma-contiguous: setup default numa cma area if not configured explicitly Feng Tang
@ 2026-05-08 11:46 ` David Hildenbrand (Arm)
2026-05-08 12:58 ` Robin Murphy
0 siblings, 1 reply; 4+ messages in thread
From: David Hildenbrand (Arm) @ 2026-05-08 11:46 UTC (permalink / raw)
To: Feng Tang
Cc: Marek Szyprowski, Robin Murphy, Ying Huang, Andrew Morton,
Lorenzo Stoakes, Liam.Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, linux-mm, Christoph Hellwig,
Catalin Marinas, Will Deacon, iommu, linux-kernel, Changrong Chen
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.
>
>> [...]
>>
>>>
>>> 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 :)
--
Cheers,
David
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] dma-contiguous: setup default numa cma area if not configured explicitly
2026-05-08 11:46 ` David Hildenbrand (Arm)
@ 2026-05-08 12:58 ` Robin Murphy
2026-05-08 20:57 ` David Hildenbrand (Arm)
0 siblings, 1 reply; 4+ messages in thread
From: Robin Murphy @ 2026-05-08 12:58 UTC (permalink / raw)
To: David Hildenbrand (Arm), Feng Tang
Cc: Marek Szyprowski, Ying Huang, Andrew Morton, Lorenzo Stoakes,
Liam.Howlett, Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan,
Michal Hocko, linux-mm, Christoph Hellwig, Catalin Marinas,
Will Deacon, iommu, linux-kernel, Changrong Chen
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 :)
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] dma-contiguous: setup default numa cma area if not configured explicitly
2026-05-08 12:58 ` Robin Murphy
@ 2026-05-08 20:57 ` David Hildenbrand (Arm)
0 siblings, 0 replies; 4+ messages in thread
From: David Hildenbrand (Arm) @ 2026-05-08 20:57 UTC (permalink / raw)
To: Robin Murphy, Feng Tang
Cc: Marek Szyprowski, Ying Huang, Andrew Morton, Lorenzo Stoakes,
Liam.Howlett, Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan,
Michal Hocko, linux-mm, Christoph Hellwig, Catalin Marinas,
Will Deacon, iommu, linux-kernel, Changrong Chen
On 5/8/26 14:58, Robin Murphy wrote:
> On 2026-05-08 12:46 pm, David Hildenbrand (Arm) wrote:
>> On 5/6/26 17:46, Feng Tang wrote:
>>>
>>> Yes, it is confusing.
>>>
>>>
>>> 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
Cool, I guess that's the right direction then, thanks.
--
Cheers,
David
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-05-08 20:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260428060550.7167-1-feng.tang@linux.alibaba.com>
[not found] ` <6dd52f8b-7092-4d02-ba24-f8b55409b7b6@kernel.org>
[not found] ` <afBxtIdWqv8pD8YE@U-2FWC9VHC-2323.local>
[not found] ` <f900172c-341a-4956-b7b7-b297418be913@kernel.org>
2026-05-06 15:46 ` [PATCH v3] dma-contiguous: setup default numa cma area if not configured explicitly Feng Tang
2026-05-08 11:46 ` David Hildenbrand (Arm)
2026-05-08 12:58 ` Robin Murphy
2026-05-08 20:57 ` David Hildenbrand (Arm)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox