> -----Original Message-----
> From: Dmitry Kozlyuk <dmitry.kozl...@gmail.com>
> Sent: Wednesday, May 13, 2020 11:43 AM
> To: Fady Bader <f...@mellanox.com>
> Cc: dev@dpdk.org; Dmitry Malloy (MESHCHANINOV)
> <dmit...@microsoft.com>; Narcisa Ana Maria Vasile
> <narcisa.vas...@microsoft.com>; Tal Shnaiderman <tal...@mellanox.com>;
> Thomas Monjalon <tho...@monjalon.net>; Harini Ramakrishnan
> <harini.ramakrish...@microsoft.com>; Omar Cardona
> <ocard...@microsoft.com>; Pallavi Kadam <pallavi.ka...@intel.com>;
> Ranjit Menon <ranjit.me...@intel.com>; John McNamara
> <john.mcnam...@intel.com>; Marko Kovacevic
> <marko.kovace...@intel.com>; Anatoly Burakov
> <anatoly.bura...@intel.com>
> Subject: Re: [PATCH v4 8/8] eal/windows: implement basic memory
> management
> 
> On Wed, 13 May 2020 08:24:12 +0000
> Fady Bader <f...@mellanox.com> wrote:
> 
> > Hi Dmitry,
> > I'm using your latest memory management patchset and getting an error
> > in the function VirualAlloc2 in eal_mem_commit, error code: 0x57
> > (ERROR_INVALID_PARAMETER). I'm using Windows server 2019 build
> 17763,
> > and followed the steps to Grant *Lock pages in memory* Privilege.
> >
> > The parameters that are sent to the function are:
> > GetCurrentProcess() is -1.
> > requested_addr is 0x0000025b`93800000.
> > Size is 0x200000 (sysInfo.dwAllocationGranularity is 0x10000).
> > Flags is 0x20007000.
> > Also, Socket_id is 0.
> >
> > The call stack is:
> > 00 dpdk_mempool_test!eal_mem_commit+0x253
> > 01 dpdk_mempool_test!alloc_seg+0x1b0
> > 02 dpdk_mempool_test!alloc_seg_walk+0x2a1
> > 03 dpdk_mempool_test!rte_memseg_list_walk_thread_unsafe+0x81
> > 04 dpdk_mempool_test!eal_memalloc_alloc_seg_bulk+0x1a5
> > 05 dpdk_mempool_test!alloc_pages_on_heap+0x13a
> > 06 dpdk_mempool_test!try_expand_heap_primary+0x1dc
> > 07 dpdk_mempool_test!try_expand_heap+0xf5
> > 08 dpdk_mempool_test!alloc_more_mem_on_socket+0x693
> > 09 dpdk_mempool_test!malloc_heap_alloc_on_heap_id+0x2a7
> > 0a dpdk_mempool_test!malloc_heap_alloc+0x184
> > 0b dpdk_mempool_test!malloc_socket+0xf9
> > 0c dpdk_mempool_test!rte_malloc_socket+0x39
> > 0d dpdk_mempool_test!rte_zmalloc_socket+0x31
> > 0e dpdk_mempool_test!rte_zmalloc+0x2d
> > 0f dpdk_mempool_test!rte_mempool_create_empty+0x1c9
> > 10 dpdk_mempool_test!rte_mempool_create+0xf8
> 
> Hi Fady,
> 
> Can you share the code snippet causing this?
> 

[snip]
+
+void*
+eal_mem_commit(void *requested_addr, size_t size, int socket_id)
+{
+       MEM_EXTENDED_PARAMETER param;
+       DWORD param_count = 0;
+       DWORD flags;
+       void *addr;
+
+       if (requested_addr != NULL) {
+               MEMORY_BASIC_INFORMATION info;
+               if (VirtualQuery(requested_addr, &info, sizeof(info)) == 0) {
+                       RTE_LOG_WIN32_ERR("VirtualQuery()");
+                       return NULL;
+               }
+
+               /* Split reserved region if only a part is committed. */
+               flags = MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER;
+               if ((info.RegionSize > size) &&
+                       !VirtualFree(requested_addr, size, flags)) {
+                       RTE_LOG_WIN32_ERR("VirtualFree(%p, %zu, "
+                               "<split placeholder>)", requested_addr, size);
+                       return NULL;
+               }
+       }
+
+       if (socket_id != SOCKET_ID_ANY) {
+               param_count = 1;
+               memset(&param, 0, sizeof(param));
+               param.Type = MemExtendedParameterNumaNode;
+               param.ULong = eal_socket_numa_node(socket_id);
+       }
+
+       flags = MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES;
+       if (requested_addr != NULL)
+               flags |= MEM_REPLACE_PLACEHOLDER;
+
+       addr = VirtualAlloc2(GetCurrentProcess(), requested_addr, size,
+               flags, PAGE_READWRITE, &param, param_count);
+       if (addr == NULL) {
+               DWORD err = GetLastError();
+               RTE_LOG_WIN32_ERR("VirtualAlloc2(%p, %zu, "
+                       "<replace placeholder>)", addr, size);
+               set_errno_from_win32_alloc_error(err);
+               return NULL;
+       }
+
+       return addr;
+}
+

> --
> Dmitry Kozlyuk

Reply via email to