Commit b42cf6ea authored by Darek Stojaczyk's avatar Darek Stojaczyk
Browse files

env/dpdk: allow changing DPDK loglevels



spdk_env_opts->env_context may now contain a DPDK-specific
string that will be appended directly into rte_eal_init().
It can be used to e.g. override the default EAL loglevel,
which was hardcoded to RTE_LOG_NOTICE so far.

This is primarily meant to be used during development.

As a test for this feature, the vtophys test app will now
set the highest possible EAL loglevel which will give us
a ton of additional debug logs.

Note: the opts->env_context field is implementation-specific
and hence the vtophys app needs to check if it's run with
our env_dpdk. As SPDK_CONFIG_ENV is a raw text not even
surrounded with quotation marks, the vtophys app needs to
do a bit of #define magic to make it a string.

Change-Id: I0b2196770e5b59a6c33d0170337c34f9f8b8466e
Signed-off-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/445111


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 9858408b
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -302,6 +302,21 @@ spdk_build_eal_cmdline(const struct spdk_env_opts *opts)
		}
	}

	/* Lower default EAL loglevel to RTE_LOG_NOTICE - normal, but significant messages.
	 * This can be overridden by specifying the same option in opts->env_context
	 */
	args = spdk_push_arg(args, &argcount, strdup("--log-level=lib.eal:6"));
	if (args == NULL) {
		return -1;
	}

	if (opts->env_context) {
		args = spdk_push_arg(args, &argcount, strdup(opts->env_context));
		if (args == NULL) {
			return -1;
		}
	}

#ifdef __linux__
	/* Set the base virtual address - it must be an address that is not in the
	 * ASAN shadow region, otherwise ASAN-enabled builds will ignore the
@@ -416,8 +431,5 @@ spdk_env_init(const struct spdk_env_opts *opts)
		spdk_env_unlink_shared_files();
	}

	/* Print only the significant EAL messages */
	rte_log_set_level(RTE_LOGTYPE_EAL, RTE_LOG_NOTICE);

	return spdk_env_dpdk_post_init();
}
+9 −0
Original line number Diff line number Diff line
@@ -33,11 +33,16 @@

#include "spdk/stdinc.h"

#include "spdk/config.h"
#include "spdk/env.h"
#include "spdk/util.h"

#include "CUnit/Basic.h"

#define __SPDK_ENV_NAME(path)	(strrchr(#path, '/') + 1)
#define _SPDK_ENV_NAME(path)	__SPDK_ENV_NAME(path)
#define SPDK_ENV_NAME		_SPDK_ENV_NAME(SPDK_CONFIG_ENV)

static void
vtophys_malloc_test(void)
{
@@ -156,6 +161,10 @@ main(int argc, char **argv)
	spdk_env_opts_init(&opts);
	opts.name = "vtophys";
	opts.core_mask = "0x1";
	if (strcmp(SPDK_ENV_NAME, "env_dpdk") == 0) {
		opts.env_context = "--log-level=lib.eal:8";
	}

	if (spdk_env_init(&opts) < 0) {
		printf("Err: Unable to initialize SPDK env\n");
		return 1;