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 <james.r.harris@intel.com>
Change-Id: I017bd4f7ed9cf6aaa141879539b099fb48f357f4
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10991
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Jim Harris 2022-01-06 08:54:37 +00:00
parent 5d68b11865
commit c833f6aa3e

View File

@ -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;