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 <james.r.harris@intel.com>
Change-Id: I7aa49e4af5f3c333fa1e7dec4e3f5b4b92e7d414
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17483
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Jim Harris 2023-04-04 03:51:54 +00:00 committed by David Ko
parent f918384212
commit 8192d7c568

View File

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