From aa8e7002ba9e69f91af7b5797a367c0340dd2ba8 Mon Sep 17 00:00:00 2001 From: Dariusz Stojaczyk Date: Fri, 23 Feb 2018 09:19:09 +0100 Subject: [PATCH] app: add -g flag hinting dpdk to create just one hugetlbfs file This makes use of the `--single-file-segments` DPDK param. Change-Id: I21ddd955841748ea087c0d006875514be56f2107 Signed-off-by: Dariusz Stojaczyk Reviewed-on: https://review.gerrithub.io/401112 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp Reviewed-by: Jim Harris --- include/spdk/env.h | 1 + include/spdk/event.h | 3 ++- lib/env_dpdk/init.c | 13 +++++++++++-- lib/event/app.c | 5 +++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/include/spdk/env.h b/include/spdk/env.h index c64ccc915..2b72b60b4 100644 --- a/include/spdk/env.h +++ b/include/spdk/env.h @@ -61,6 +61,7 @@ struct spdk_env_opts { int master_core; int mem_size; bool no_pci; + bool hugepage_single_segments; /** Opaque context for use of the env implementation. */ void *env_context; diff --git a/include/spdk/event.h b/include/spdk/event.h index 39e78ec23..0bdded361 100644 --- a/include/spdk/event.h +++ b/include/spdk/event.h @@ -88,6 +88,7 @@ struct spdk_app_opts { int master_core; int mem_size; bool no_pci; + bool hugepage_single_segments; enum spdk_log_level print_level; /* The maximum latency allowed when passing an event @@ -185,7 +186,7 @@ int spdk_app_parse_core_mask(const char *mask, struct spdk_cpuset *cpumask); */ struct spdk_cpuset *spdk_app_get_core_mask(void); -#define SPDK_APP_GETOPT_STRING "c:de:hi:m:n:p:qr:s:t:" +#define SPDK_APP_GETOPT_STRING "c:de:ghi:m:n:p:qr:s:t:" enum spdk_app_parse_args_rvals { SPDK_APP_PARSE_ARGS_HELP = 0, diff --git a/lib/env_dpdk/init.c b/lib/env_dpdk/init.c index 036d1a2ef..ec16a003d 100644 --- a/lib/env_dpdk/init.c +++ b/lib/env_dpdk/init.c @@ -242,6 +242,14 @@ spdk_build_eal_cmdline(const struct spdk_env_opts *opts) } } + /* create just one hugetlbfs file */ + if (opts->hugepage_single_segments) { + args = spdk_push_arg(args, &argcount, _sprintf_alloc("--single-file-segments")); + if (args == NULL) { + return -1; + } + } + #ifdef __linux__ if (opts->shm_id < 0) { args = spdk_push_arg(args, &argcount, _sprintf_alloc("--file-prefix=spdk_pid%d", @@ -322,12 +330,13 @@ int spdk_env_init(const struct spdk_env_opts *opts) return -1; } - if (opts->shm_id < 0) { + if (opts->shm_id < 0 && !opts->hugepage_single_segments) { /* * Unlink hugepage and config info files after init. This will ensure they get * deleted on app exit, even if the app crashes and does not exit normally. * Only do this when not in multi-process mode, since for multi-process other - * apps will need to open these files. + * apps will need to open these files. These files are not created for + * "single file segments". */ spdk_env_unlink_shared_files(); } diff --git a/lib/event/app.c b/lib/event/app.c index 34247cfec..78f077f6f 100644 --- a/lib/event/app.c +++ b/lib/event/app.c @@ -359,6 +359,7 @@ spdk_app_start(struct spdk_app_opts *opts, spdk_event_fn start_fn, env_opts.master_core = opts->master_core; env_opts.mem_size = opts->mem_size; env_opts.no_pci = opts->no_pci; + env_opts.hugepage_single_segments = opts->hugepage_single_segments; if (spdk_env_init(&env_opts) < 0) { SPDK_ERRLOG("Unable to initialize SPDK env\n"); @@ -492,6 +493,7 @@ usage(char *executable_name, struct spdk_app_opts *default_opts, void (*app_usag printf(" -c config config file (default %s)\n", default_opts->config_file); printf(" -d disable coredump file enabling\n"); printf(" -e mask tracepoint group mask for spdk trace buffers (default 0x0)\n"); + printf(" -g force creating just one hugetlbfs file\n"); printf(" -h show this usage\n"); printf(" -i shared memory ID (optional)\n"); printf(" -m mask core mask for DPDK\n"); @@ -543,6 +545,9 @@ spdk_app_parse_args(int argc, char **argv, struct spdk_app_opts *opts, case 'e': opts->tpoint_group_mask = optarg; break; + case 'g': + opts->hugepage_single_segments = true; + break; case 'h': usage(argv[0], &default_opts, app_usage); rval = SPDK_APP_PARSE_ARGS_HELP;