[PATCH v29 08/13] eal: initialize log before everything else
Stephen Hemminger
stephen at networkplumber.org
Fri Oct 25 23:45:13 CEST 2024
In order for all log messages (including CPU mismatch) to
come out through the logging library, it must be initialized
as early in rte_eal_init() as possible on all platforms.
Where it was done before was likely historical based on
the support of non-OS isolated CPU's which required a shared
memory buffer; that support was dropped before DPDK was
publicly released.
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla at linux.microsoft.com>
Acked-by: Morten Brørup <mb at smartsharesystems.com>
Acked-by: Bruce Richardson <bruce.richardson at intel.com>
Acked-by: Chengwen Feng <fengchengwen at huawei.com>
---
lib/eal/freebsd/eal.c | 13 ++++++++++---
lib/eal/linux/eal.c | 14 +++++++++-----
lib/eal/windows/eal.c | 8 ++++++--
lib/log/log_internal.h | 6 ++++++
4 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index a609d40ee0..8631a20eae 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -52,6 +52,7 @@
#include "eal_options.h"
#include "eal_memcfg.h"
#include "eal_trace.h"
+#include "log_internal.h"
#define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL)
@@ -546,6 +547,15 @@ rte_eal_init(int argc, char **argv)
bool has_phys_addr;
enum rte_iova_mode iova_mode;
+ /* setup log as early as possible */
+ if (eal_log_level_parse(argc, argv) < 0) {
+ rte_eal_init_alert("invalid log arguments.");
+ rte_errno = EINVAL;
+ return -1;
+ }
+
+ eal_log_init(getprogname());
+
/* checks if the machine is adequate */
if (!rte_cpu_is_supported()) {
rte_eal_init_alert("unsupported cpu type.");
@@ -572,9 +582,6 @@ rte_eal_init(int argc, char **argv)
/* clone argv to report out later in telemetry */
eal_save_args(argc, argv);
- /* set log level as early as possible */
- eal_log_level_parse(argc, argv);
-
if (rte_eal_cpu_init() < 0) {
rte_eal_init_alert("Cannot detect lcores.");
rte_errno = ENOTSUP;
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 0c44d0b6e3..62d3d281c4 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -926,6 +926,15 @@ rte_eal_init(int argc, char **argv)
struct internal_config *internal_conf =
eal_get_internal_configuration();
+ /* setup log as early as possible */
+ if (eal_log_level_parse(argc, argv) < 0) {
+ rte_eal_init_alert("invalid log arguments.");
+ rte_errno = EINVAL;
+ return -1;
+ }
+
+ eal_log_init(program_invocation_short_name);
+
/* checks if the machine is adequate */
if (!rte_cpu_is_supported()) {
rte_eal_init_alert("unsupported cpu type.");
@@ -949,9 +958,6 @@ rte_eal_init(int argc, char **argv)
eal_reset_internal_config(internal_conf);
- /* set log level as early as possible */
- eal_log_level_parse(argc, argv);
-
/* clone argv to report out later in telemetry */
eal_save_args(argc, argv);
@@ -1103,8 +1109,6 @@ rte_eal_init(int argc, char **argv)
#endif
}
- eal_log_init(program_invocation_short_name);
-
#ifdef VFIO_PRESENT
if (rte_vfio_enable("vfio")) {
rte_eal_init_alert("Cannot init VFIO");
diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c
index cd8420a82c..33f044d7cc 100644
--- a/lib/eal/windows/eal.c
+++ b/lib/eal/windows/eal.c
@@ -249,9 +249,13 @@ rte_eal_init(int argc, char **argv)
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
char thread_name[RTE_THREAD_NAME_SIZE];
- eal_log_init(NULL);
+ if (eal_log_level_parse(argc, argv) < 0) {
+ rte_eal_init_alert("invalid log arguments.");
+ rte_errno = EINVAL;
+ return -1;
+ }
- eal_log_level_parse(argc, argv);
+ eal_log_init(NULL);
if (eal_create_cpu_map() < 0) {
rte_eal_init_alert("Cannot discover CPU and NUMA.");
diff --git a/lib/log/log_internal.h b/lib/log/log_internal.h
index 3c46328e7b..d5fabd7ef7 100644
--- a/lib/log/log_internal.h
+++ b/lib/log/log_internal.h
@@ -16,6 +16,12 @@
__rte_internal
void eal_log_init(const char *id);
+/*
+ * Determine where log data is written when no call to rte_openlog_stream.
+ */
+__rte_internal
+void eal_log_set_default(FILE *default_log);
+
/*
* Save a log option for later.
*/
--
2.45.2
More information about the dev
mailing list