[dpdk-dev] [PATCH v7 04/11] eal/mem: extract common code for memseg list initialization

Tal Shnaiderman talshn at mellanox.com
Tue Jun 9 13:14:56 CEST 2020


> Subject: [PATCH v7 04/11] eal/mem: extract common code for memseg list
> initialization
> 
> All supported OS create memory segment lists (MSL) and reserve VA space
> for them in a nearly identical way. Move common code into EAL private
> functions to reduce duplication.
> 
> Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk at gmail.com>
> ---
>  lib/librte_eal/common/eal_common_memory.c |  97
> ++++++++++++++++++
>  lib/librte_eal/common/eal_private.h       |  62 ++++++++++++
>  lib/librte_eal/freebsd/eal_memory.c       |  94 ++++--------------
>  lib/librte_eal/linux/eal_memory.c         | 115 +++++-----------------
>  4 files changed, 200 insertions(+), 168 deletions(-)
> 
> diff --git a/lib/librte_eal/common/eal_common_memory.c
> b/lib/librte_eal/common/eal_common_memory.c
> index f9fbd3e4e..3325d8c35 100644
> --- a/lib/librte_eal/common/eal_common_memory.c
> +++ b/lib/librte_eal/common/eal_common_memory.c

[snip]

> +void
> +eal_memseg_list_populate(struct rte_memseg_list *msl, void *addr, int
> +n_segs) {
> +	size_t page_sz = msl->page_sz;
> +	int i;
> +
> +	for (i = 0; i < n_segs; i++) {
> +		struct rte_fbarray *arr = &msl->memseg_arr;
> +		struct rte_memseg *ms = rte_fbarray_get(arr, i);

Since rte_fbarray_get() can return NULL you should verify *ms isn't dereferenced.

> +
> +		if (rte_eal_iova_mode() == RTE_IOVA_VA)
> +			ms->iova = (uintptr_t)addr;
> +		else
> +			ms->iova = RTE_BAD_IOVA;
> +		ms->addr = addr;
> +		ms->hugepage_sz = page_sz;
> +		ms->socket_id = 0;
> +		ms->len = page_sz;
> +
> +		rte_fbarray_set_used(arr, i);
> +
> +		addr = RTE_PTR_ADD(addr, page_sz);
> +	}
> +}

[snip]

> --
> 2.25.4



More information about the dev mailing list