From 41c16a6dab72443ba1f0b73ddedb225a126c7507 Mon Sep 17 00:00:00 2001 From: Tomasz Zawadzki Date: Tue, 20 Dec 2022 11:56:06 +0100 Subject: [PATCH] env_dpdk: clean up DPDK args print during init When initializing SPDK, the used DPDK args are printed. Unfortunately before each argument a timestamp is added. Rather than use SPDK_PRINTF for each argument, bunch up whole line to be printed and then print it in one go. Please see before: [2022-12-20 13:52:05.647131] [ DPDK EAL parameters: [2022-12-20 13:52:05.647145] spdk_tgt [2022-12-20 13:52:05.647159] --no-shconf [2022-12-20 13:52:05.647170] -c 0x1 [2022-12-20 13:52:05.647185] --huge-unlink [2022-12-20 13:52:05.647199] --log-level=lib.eal:6 [2022-12-20 13:52:05.647221] --log-level=lib.cryptodev:5 [2022-12-20 13:52:05.647232] --log-level=user1:6 [2022-12-20 13:52:05.647251] --iova-mode=pa [2022-12-20 13:52:05.647261] --base-virtaddr=0x200000000000 [2022-12-20 13:52:05.647275] --match-allocations [2022-12-20 13:52:05.647286] --file-prefix=spdk_pid1352179 [2022-12-20 13:52:05.647307] ] And after: [2022-12-20 13:52:29.038353] [ DPDK EAL parameters: spdk_tgt --no-shconf -c 0x1 --huge-unlink --log-level=lib.eal:6 --log-level=lib.cryptodev:5 --log-level=user1:6 --iova-mode=pa --base-virtaddr=0x200000000000 --match-allocations --file-prefix=spdk_pid1358716 ] Change-Id: I4c6c25818ae99bad942bf61ab590f971d339ffc6 Signed-off-by: Tomasz Zawadzki Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16031 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Jim Harris --- lib/env_dpdk/init.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/env_dpdk/init.c b/lib/env_dpdk/init.c index 38c293d06..95a6371de 100644 --- a/lib/env_dpdk/init.c +++ b/lib/env_dpdk/init.c @@ -519,6 +519,7 @@ int spdk_env_init(const struct spdk_env_opts *opts) { char **dpdk_args = NULL; + char *args_print = NULL, *args_tmp = NULL; int i, rc; int orig_optind; bool legacy_mem; @@ -550,11 +551,22 @@ spdk_env_init(const struct spdk_env_opts *opts) } SPDK_PRINTF("Starting %s / %s initialization...\n", SPDK_VERSION_STRING, rte_version()); - SPDK_PRINTF("[ DPDK EAL parameters: "); - for (i = 0; i < g_eal_cmdline_argcount; i++) { - SPDK_PRINTF("%s ", g_eal_cmdline[i]); + + args_print = _sprintf_alloc("[ DPDK EAL parameters: "); + if (args_print == NULL) { + return -ENOMEM; } - SPDK_PRINTF("]\n"); + for (i = 0; i < g_eal_cmdline_argcount; i++) { + args_tmp = args_print; + args_print = _sprintf_alloc("%s%s ", args_tmp, g_eal_cmdline[i]); + if (args_print == NULL) { + free(args_tmp); + return -ENOMEM; + } + free(args_tmp); + } + SPDK_PRINTF("%s]\n", args_print); + free(args_print); /* DPDK rearranges the array we pass to it, so make a copy * before passing so we can still free the individual strings