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

Thomas Monjalon thomas at monjalon.net
Fri Jun 12 17:39:11 CEST 2020


10/06/2020 16:27, Dmitry Kozlyuk:
> +eal_memseg_list_init_named(struct rte_memseg_list *msl, const char *name,
> +		uint64_t page_sz, int n_segs, int socket_id, bool heap)
> +{
> +	if (rte_fbarray_init(&msl->memseg_arr, name, n_segs,
> +			sizeof(struct rte_memseg))) {
> +		RTE_LOG(ERR, EAL, "Cannot allocate memseg list: %s\n",
> +			rte_strerror(rte_errno));
> +		return -1;
> +	}
> +
> +	msl->page_sz = page_sz;
> +	msl->socket_id = socket_id;
> +	msl->base_va = NULL;
> +	msl->heap = heap;
> +
> +	RTE_LOG(DEBUG, EAL,
> +		"Memseg list allocated at socket %i, page size 0x%zxkB\n",
> +		socket_id, (size_t)page_sz >> 10);

page_sz is uint64_t, so the right printf specifier is PRIx64.

[...]
> +#ifndef RTE_EXEC_ENV_WINDOWS
> +		/* The hint would be misleading on Windows, but this function

Would be better to explain the reason of misleading
in this comment.

> +		 * is called from many places, including common code,
> +		 * so don't duplicate the message.
> +		 */
> +		if (rte_errno == EADDRNOTAVAIL)
> +			RTE_LOG(ERR, EAL, "Cannot reserve %llu bytes at [%p] - "
> +				"please use '--" OPT_BASE_VIRTADDR "' option\n",
> +				(unsigned long long)mem_sz, msl->base_va);
> +#endif

[...]
> +			if (memseg_list_alloc(msl) < 0) {
> +				RTE_LOG(ERR, EAL,
> +					"Cannot preallocate %zukB hugepages\n",
> +					page_sz >> 10);

page_sz is uint64_t, so the right printf specifier is PRIx64.





More information about the dev mailing list