[dpdk-dev] [PATCH v4 8/8] eal/windows: implement basic memory management

Ranjit Menon ranjit.menon at intel.com
Wed Apr 29 03:18:20 CEST 2020


On 4/28/2020 4:50 PM, Dmitry Kozlyuk wrote:
> Basic memory management supports core libraries and PMDs operating in
> IOVA as PA mode. It uses a kernel-mode driver, virt2phys, to obtain
> IOVAs of hugepages allocated from user-mode. Multi-process mode is not
> implemented and is forcefully disabled at startup.
> 
> Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk at gmail.com>
> ---

[snip]

> +void *
> +eal_mem_reserve(void *requested_addr, size_t size, int flags)
> +{
> +	void *virt;
> +
> +	/* Windows requires hugepages to be committed. */
> +	if (flags & EAL_RESERVE_HUGEPAGES) {
> +		rte_errno = ENOTSUP;
> +		return NULL;
> +	}
> +
> +	virt = VirtualAlloc2(GetCurrentProcess(), requested_addr, size,
> +		MEM_RESERVE | MEM_RESERVE_PLACEHOLDER, PAGE_NOACCESS,
> +		NULL, 0);
> +	if (virt == NULL) {
> +		DWORD err = GetLastError();
> +		RTE_LOG_WIN32_ERR("VirtualAlloc2()");
> +		set_errno_from_win32_alloc_error(err);
> +	}
> +
> +	if ((flags & EAL_RESERVE_FORCE_ADDRESS) && (virt != requested_addr)) {
> +		if (!VirtualFree(virt, 0, MEM_RELEASE))

Shouldn't this be VirtualFreeEx() here?

> +			RTE_LOG_WIN32_ERR("VirtualFree()");
> +		rte_errno = ENOMEM;
> +		return NULL;
> +	}
> +
> +	return virt;
> +}
> +

ranjit m.


More information about the dev mailing list