From c833f6aa3eb61cc9e116b8858d1f29d5fcdcedf0 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Thu, 6 Jan 2022 08:54:37 +0000 Subject: [PATCH] env_dpdk: unlink hugepages if shm_id is not specified The only release to not unlink hugepages after mmaping them is for multiprocess. But if shm_id is not specified, then we aren't using multiprocess. This ensures that all hugepages get released when the process exits, even if there is memory in those hugepages that was not freed during process shutdown. Make sure we don't enable both huge-unlink and single-file-segments at the same time though, DPDK doesn't support that. Note that even when using multi-process, if hugepages aren't released, they aren't really leaked. DPDK will clean them up next time the application runs. Fixes issue #2267. Signed-off-by: Jim Harris Change-Id: I017bd4f7ed9cf6aaa141879539b099fb48f357f4 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10991 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Ben Walker --- lib/env_dpdk/init.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/env_dpdk/init.c b/lib/env_dpdk/init.c index 6b7e660ea..53124d559 100644 --- a/lib/env_dpdk/init.c +++ b/lib/env_dpdk/init.c @@ -342,7 +342,13 @@ build_eal_cmdline(const struct spdk_env_opts *opts) } /* unlink hugepages after initialization */ - if (opts->unlink_hugepage) { + /* Note: Automatically unlink hugepage when shm_id < 0, since it means we're not using + * multi-process so we don't need the hugepage links anymore. But we need to make sure + * we don't specify --huge-unlink implicitly if --single-file-segments was specified since + * DPDK doesn't support that. + */ + if (opts->unlink_hugepage || + (opts->shm_id < 0 && !opts->hugepage_single_segments)) { args = push_arg(args, &argcount, _sprintf_alloc("--huge-unlink")); if (args == NULL) { return -1;