From 8192d7c568cde943d8242a97e555ac6e5fd64b54 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Tue, 4 Apr 2023 03:51:54 +0000 Subject: [PATCH] env_dpdk: omit huge-related options when --no-huge specified If user passes --no-huge as part of env_context, do not add other huge-related options to the EAL command line. Instead emit an error message and return failure, if any of them were specified explicitly. Fixes c833f6aa ("env_dpdk: unlink hugepages if shm_id is not specified") Fixes issue #2973. Signed-off-by: Jim Harris Change-Id: I7aa49e4af5f3c333fa1e7dec4e3f5b4b92e7d414 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17483 Reviewed-by: Aleksey Marchuk Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Reviewed-by: Ben Walker --- lib/env_dpdk/init.c | 54 ++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/lib/env_dpdk/init.c b/lib/env_dpdk/init.c index 95a6371de..2625a8290 100644 --- a/lib/env_dpdk/init.c +++ b/lib/env_dpdk/init.c @@ -291,33 +291,41 @@ build_eal_cmdline(const struct spdk_env_opts *opts) } } - /* create just one hugetlbfs file */ - if (opts->hugepage_single_segments) { - args = push_arg(args, &argcount, _sprintf_alloc("--single-file-segments")); - if (args == NULL) { + if (opts->env_context && strstr(opts->env_context, "--no-huge") != NULL) { + if (opts->hugepage_single_segments || opts->unlink_hugepage || opts->hugedir) { + fprintf(stderr, "--no-huge invalid with other hugepage options\n"); + free_args(args, argcount); return -1; } - } - - /* unlink hugepages after initialization */ - /* 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; + } else { + /* create just one hugetlbfs file */ + if (opts->hugepage_single_segments) { + args = push_arg(args, &argcount, _sprintf_alloc("--single-file-segments")); + if (args == NULL) { + return -1; + } } - } - /* use a specific hugetlbfs mount */ - if (opts->hugedir) { - args = push_arg(args, &argcount, _sprintf_alloc("--huge-dir=%s", opts->hugedir)); - if (args == NULL) { - return -1; + /* unlink hugepages after initialization */ + /* 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; + } + } + + /* use a specific hugetlbfs mount */ + if (opts->hugedir) { + args = push_arg(args, &argcount, _sprintf_alloc("--huge-dir=%s", opts->hugedir)); + if (args == NULL) { + return -1; + } } }