> System meory management is implemented differently for POSIX and > Windows. Introduce wrapper functions for operations used across DPDK: > > * rte_mem_map() > Create memory mapping for a regular file or a page file (swap). > This supports mapping to a reserved memory region even on Windows. > > * rte_mem_unmap() > Remove mapping created with rte_mem_map(). > > * rte_get_page_size() > Obtain default system page size. > > * rte_mem_lock() > Make arbitrary-sized memory region non-swappable. > > Wrappers follow POSIX semantics limited to DPDK tasks, but their signatures > deliberately differ from POSIX ones to be more safe and expressive. > > Signed-off-by: Dmitry Kozlyuk <dmitry.kozl...@gmail.com> > --- > config/meson.build | 10 +- > lib/librte_eal/common/eal_private.h | 51 +++- > lib/librte_eal/include/rte_memory.h | 68 +++++ > lib/librte_eal/rte_eal_exports.def | 4 + > lib/librte_eal/rte_eal_version.map | 4 + > lib/librte_eal/unix/eal_memory.c | 113 +++++++ > lib/librte_eal/unix/meson.build | 1 + > lib/librte_eal/windows/eal.c | 6 + > lib/librte_eal/windows/eal_memory.c | 437 > +++++++++++++++++++++++++++ lib/librte_eal/windows/eal_windows.h |
<Snip!> > +eal_mem_win32api_init(void) > +{ > + static const char library_name[] = "kernelbase.dll"; > + static const char function[] = "VirtualAlloc2"; > + > + OSVERSIONINFO info; > + HMODULE library = NULL; > + int ret = 0; > + > + /* Already done. */ > + if (VirtualAlloc2 != NULL) > + return 0; > + > + /* IsWindows10OrGreater() may also be unavailable. */ > + memset(&info, 0, sizeof(info)); > + info.dwOSVersionInfoSize = sizeof(info); > + GetVersionEx(&info); I'd remove the GetVersionEx check entirely and add the comments regarding OS dependency to the RTE_LOG Of the LoadLibraryA failure below, GetVersionEx returns the Windows 8 OS version on newer servers Also, it looks like not all Win2016 servers versions support VirtualAlloc2, I'm using Microsoft Windows Server 2016 Datacenter Version 10.0.14393 and LoadLibraryA failed to load VirtualAlloc2. > + /* Checking for Windows 10+ will also detect Windows Server 2016+. > + * Do not abort, because Windows may report false version > depending > + * on executable manifest, compatibility mode, etc. > + */ > + if (info.dwMajorVersion < 10) > + RTE_LOG(DEBUG, EAL, "Windows 10+ or Windows Server > 2016+ " > + "is required for advanced memory features\n"); > + > + library = LoadLibraryA(library_name); > + if (library == NULL) { > + RTE_LOG_WIN32_ERR("LoadLibraryA(\"%s\")", > library_name); > + return -1; > + } > +