diff mbox series

mem: fix cleanup on Windows

Message ID 20210324180128.32752-1-dmitry.kozliuk@gmail.com (mailing list archive)
State Superseded, archived
Headers show
Series mem: fix cleanup on Windows | expand

Checks

Context Check Description
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/checkpatch success coding style OK

Commit Message

Dmitry Kozlyuk March 24, 2021, 6:01 p.m. UTC
rte_mem_unmap() called from rte_eal_memory_detach() fails on Windows
with message "EAL: Could not unmap memory: No error". This is because
on Windows memory is not allocated using mapping. Confusing "No error"
is caused by using errno instead of rte_errno set by rte_mem_unmap().

Multi-process is not supported on Windows and --in-memory is forced,
so detaching memory is not needed on cleanup. Bypass the function
in this case. Fix error handling to produce proper log message.

Fixes: dfbc61a2f9a6 ("mem: detach memsegs on cleanup")
Cc: Anatoly Burakov <anatoly.burakov@intel.com>

Reported-by: Jie Zhou <jizh@microsoft.com>
Suggested-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
---
 lib/librte_eal/common/eal_common_memory.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

David Marchand March 24, 2021, 6:35 p.m. UTC | #1
On Wed, Mar 24, 2021 at 7:01 PM Dmitry Kozlyuk <dmitry.kozliuk@gmail.com> wrote:
>
> rte_mem_unmap() called from rte_eal_memory_detach() fails on Windows
> with message "EAL: Could not unmap memory: No error". This is because
> on Windows memory is not allocated using mapping. Confusing "No error"
> is caused by using errno instead of rte_errno set by rte_mem_unmap().
>
> Multi-process is not supported on Windows and --in-memory is forced,
> so detaching memory is not needed on cleanup. Bypass the function
> in this case. Fix error handling to produce proper log message.
>
> Fixes: dfbc61a2f9a6 ("mem: detach memsegs on cleanup")
> Cc: Anatoly Burakov <anatoly.burakov@intel.com>
>
> Reported-by: Jie Zhou <jizh@microsoft.com>
> Suggested-by: David Marchand <david.marchand@redhat.com>
> Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> ---
>  lib/librte_eal/common/eal_common_memory.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
> index 0e99986d3d..9ef9c65ac8 100644
> --- a/lib/librte_eal/common/eal_common_memory.c
> +++ b/lib/librte_eal/common/eal_common_memory.c
> @@ -1010,6 +1010,13 @@ rte_eal_memory_detach(void)
>         size_t page_sz = rte_mem_page_size();
>         unsigned int i;
>
> +#ifdef RTE_EXEC_ENV_WINDOWS
> +       /* Multi-process is not supported, detaching is not needed.
> +        * mcfg->mp_status can't be used: it's always "unknown" on Windows.
> +        */
> +       return 0;
> +#endif
> +

My suggestion was more like:
if (eal_get_internal_configuration()->in_memory == 1)
    return 0;
diff mbox series

Patch

diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
index 0e99986d3d..9ef9c65ac8 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -1010,6 +1010,13 @@  rte_eal_memory_detach(void)
 	size_t page_sz = rte_mem_page_size();
 	unsigned int i;
 
+#ifdef RTE_EXEC_ENV_WINDOWS
+	/* Multi-process is not supported, detaching is not needed.
+	 * mcfg->mp_status can't be used: it's always "unknown" on Windows.
+	 */
+	return 0;
+#endif
+
 	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
 
 	/* detach internal memory subsystem data first */
@@ -1032,7 +1039,7 @@  rte_eal_memory_detach(void)
 		if (!msl->external)
 			if (rte_mem_unmap(msl->base_va, msl->len) != 0)
 				RTE_LOG(ERR, EAL, "Could not unmap memory: %s\n",
-						strerror(errno));
+						rte_strerror(rte_errno));
 
 		/*
 		 * we are detaching the fbarray rather than destroying because