[PATCH v4] lib: set/get max memzone segments

Burakov, Anatoly anatoly.burakov at intel.com
Thu May 25 16:53:47 CEST 2023


On 5/24/2023 11:25 PM, Ophir Munk wrote:
> Currently, the max memzones count constat (RTE_MAX_MEMZONE) is used to
> decide how many memzones a DPDK application can have. This value could
> technically be changed by manually editing `rte_config.h` before
> compilation, but if DPDK is already compiled, that option is not useful.
> There are certain use cases that would benefit from making this value
> configurable.
> 
> This commit addresses the issue by adding a new API to set the max
> number of memzones before EAL initialization (while using the old
> constant as default value), as well as an API to get current maximum
> number of memzones.
> 
> Signed-off-by: Ophir Munk <ophirmu at nvidia.com>
> Acked-by: Morten Brørup <mb at smartsharesystems.com>
> ---


> +
> +int
> +rte_memzone_max_set(size_t max)
> +{
> +	struct rte_mem_config *mcfg;
> +
> +	if (eal_get_internal_configuration()->init_complete > 0)
> +		return -1;
> +
> +	mcfg = rte_eal_get_configuration()->mem_config;
> +	if (!mcfg)
> +		return -1;
> +
> +	mcfg->max_memzone = max;
> +
> +	return 0;
> +}

Would this even work? AFAIR mem_config is only available some time 
during EAL init, not before (mem_config pointer will be NULL at that point).

I suggest the following flow:

set():

if init_complete => return -1
else => set local static value

get():

if init_complete => return memzones.count
else => return local static value (set to our default)

That way we don't actually need the memconfig, and multiprocess will 
work because memzones.count is shared between primary and secondary anyway.

-- 
Thanks,
Anatoly



More information about the dev mailing list