mem: fix cleanup when multi-process is disabled
authorDmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Wed, 24 Mar 2021 19:32:26 +0000 (22:32 +0300)
committerDavid Marchand <david.marchand@redhat.com>
Fri, 26 Mar 2021 16:17:45 +0000 (17:17 +0100)
commitb2f24588b5681ab4ea0b90e9dad80a5eb3829142
tree2c3c8fbddb1f15f335b4adbdb73784d5070eb24a
parent1325a1ffd98dcec9a083e3800833211822c37e74
mem: fix cleanup when multi-process is disabled

rte_eal_memory_detach() did not account for cases where multi-process
mode is disabled: --in-memory and --no-shconf. This resulted
in unmapping memory that had not been mapped, which caused errors:

    EAL: Could not unmap memory: No error   (Windows)
    EAL: Cannot munmap(0x1d47f40, 0x7000): Invalid argument  (Linux)

Confusing "No error" was caused by using errno instead of rte_errno
set by rte_mem_unmap().

Skip detaching memory altogether when --in-memory is specified.
Skip unmapping configuration when it's not shared.
Fix and add error handling to produce proper log messages.

Fixes: dfbc61a2f9a6 ("mem: detach memsegs on cleanup")

Reported-by: Jie Zhou <jizh@microsoft.com>
Suggested-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Acked-by: Ranjit Menon <ranjit.menon@intel.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
lib/librte_eal/common/eal_common_memory.c