Re: [PATCH v2] dma-contiguous: support percentage sizes in cma_pernuma= and numa_cma=
From: Graf (AWS), Alexander
Date: Thu Nov 19 2026 - 07:27:32 EST
On 19.11.26 12:19, Marek Szyprowski wrote:
> On 14.11.2026 15:53, Alexander Graf wrote:
>> While CMA_SIZE_PERCENTAGE supports percentages for built-in defaults, the
>> CMA allocation kernel parameters currently only take a fixed size argument.
>> That makes it difficult to have a single system image that sizes its CMA
>> allocation based on the available memory. To use CMA as backing pool for
>> large, physically contiguous guest memory, I want to be able to say
>> "allocate 90% of system RAM minus 1 GiB for CMA". Per NUMA node.
>>
>> Extend the CMA parser logic to accept command line options like this:
>>
>> cma_pernuma=80% numa_cma=0:95%-1G,1:4G
>>
>> To avoid incomplete allocations on parsing errors, check for them
>> before actually allocating.
>
> This looks like an over-engineered feature. I doubt that kernel is the right
> place to implement such advanced sizing. If You need to explicitly control
> the amount of CMA on the target machines, maybe You could do it in some
> scripts deploying the kernel configuration? Calculating it there should be
> much more flexible imho...
It allows to push more policy into a generic boot image, yes. I suppose
we could push that policy into other bits of pre-boot logic, such as the
Linux EFI loader, but I'm not convinced it's a net win for simplicity.
Pushing it into a boot load would mean pushing into UKI for UKI-based
boot flows, which means bloating systemd-boot. Again, not really great.
Ideally all of this would be policy that only takes effect later at
boot, so that we don't require pre-boot logic or a reboot. For this to
work, we would need to have Linux restrict its memory allocations to a
small'ish region instead of spreading them, maybe to the KHO scratch
region, or maybe by favoring allocations in phys addr order. At least
until the boot is at a point where you could perform the allocation. And
then we would also have large physically contiguous blocks available to
allocate from and potentially change the tag to CMA.
Any thoughts on how we could best do this?
Alex