Re: [PATCH v2] dma-contiguous: support percentage sizes in cma_pernuma= and numa_cma=
From: Marek Szyprowski
Date: Thu Nov 19 2026 - 06:20:13 EST
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...
> Signed-off-by: Alexander Graf <graf@xxxxxxxxxx>
> ---
> v1 -> v2:
>
> - Reject an empty numa_cma= and a trailing comma (Sashiko)
> - Keep the last valid size for each option or node, so an explicit 0
> now overrides a percentage (Sashiko)
> - Parse percentages as plain decimal, and reject sizes that a 32-bit
> phys_addr_t cannot hold
> - Reject a bare cma_pernuma or numa_cma without "=", which mainline
> dereferences as NULL
> - Rework the kernel-parameters.txt text accordingly
>
> v1: https://lore.kernel.org/all/20261111140440.43024-1-graf@xxxxxxxxxx/
>
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland