env_dpdk: don't free segments on newer DPDK versions

We specify the --match-allocations rte init parameter
now, which gives us guarantees that memory will be
freed in the same units it was allocated.

Note that if user initialized DPDK separately from
SPDK, we aren't sure if --match-allocations was
specified, so will still mark the segments to not
be freed.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I599747d4b917e91adfabf64c904cd7891a77b3cf

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446459
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
Jim Harris 2019-02-27 10:50:06 -07:00
parent 577b667ac3
commit 0871b38206

View File

@ -45,6 +45,7 @@
#include "spdk/likely.h"
#include "spdk/queue.h"
#include "spdk/util.h"
#include "spdk/env_dpdk.h"
#ifdef __FreeBSD__
#define SPDK_VFIO_ENABLED 0
@ -702,9 +703,25 @@ memory_hotplug_cb(enum rte_mem_event event_type,
if (event_type == RTE_MEM_EVENT_ALLOC) {
spdk_mem_register((void *)addr, len);
/* Now mark each segment so that DPDK won't later free it.
* This ensures we don't have to deal with the memory
* getting freed in different units than it was allocated.
#if RTE_VERSION >= RTE_VERSION_NUM(19, 02, 0, 0)
if (!spdk_env_dpdk_external_init()) {
return;
}
#endif
/* Prior to DPDK 19.02, we have to worry about DPDK
* freeing memory in different units than it was allocated.
* That doesn't work with things like RDMA MRs. So for
* those versions of DPDK, mark each segment so that DPDK
* won't later free it. That ensures we don't have to deal
* with that scenario.
*
* DPDK 19.02 added the --match-allocations RTE flag to
* avoid this condition.
*
* Note: if the user initialized DPDK separately, we can't
* be sure that --match-allocations was specified, so need
* to still mark the segments so they aren't freed.
*/
while (len > 0) {
struct rte_memseg *seg;