[v10,04/10] eal: initialize log earlier in startup

Message ID 20240321161146.340421-5-stephen@networkplumber.org (mailing list archive)
State Superseded, archived
Headers
Series Logging enhancements. |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger March 21, 2024, 4 p.m. UTC
  Want to make sure that as many log messages as possible
get added with the real log stream. Despite the comment,
there is no dependency on memzones in current code.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/freebsd/eal.c       | 14 +++++++-------
 lib/eal/linux/eal.c         | 16 ++++++++--------
 lib/eal/unix/eal_unix_log.c |  0
 lib/log/log_unix.c          |  4 ++--
 4 files changed, 17 insertions(+), 17 deletions(-)
 create mode 100644 lib/eal/unix/eal_unix_log.c
  

Patch

diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index 94927472edfe..777770176339 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -571,6 +571,13 @@  rte_eal_init(int argc, char **argv)
 	/* set log level as early as possible */
 	eal_log_level_parse(argc, argv);
 
+	if (eal_log_init(getprogname(), internal_conf->syslog_facility) < 0) {
+		rte_eal_init_alert("Cannot init logging.");
+		rte_errno = ENOMEM;
+		rte_atomic_store_explicit(&run_once, 0, rte_memory_order_relaxed);
+		return -1;
+	}
+
 	if (rte_eal_cpu_init() < 0) {
 		rte_eal_init_alert("Cannot detect lcores.");
 		rte_errno = ENOTSUP;
@@ -719,13 +726,6 @@  rte_eal_init(int argc, char **argv)
 #endif
 	}
 
-	if (eal_log_init(getprogname(), internal_conf->syslog_facility) < 0) {
-		rte_eal_init_alert("Cannot init logging.");
-		rte_errno = ENOMEM;
-		rte_atomic_store_explicit(&run_once, 0, rte_memory_order_relaxed);
-		return -1;
-	}
-
 	/* in secondary processes, memory init may allocate additional fbarrays
 	 * not present in primary processes, so to avoid any potential issues,
 	 * initialize memzones first.
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index bffeb1f34eb9..e515f3cbc8a8 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -959,6 +959,14 @@  rte_eal_init(int argc, char **argv)
 	/* clone argv to report out later in telemetry */
 	eal_save_args(argc, argv);
 
+	if (eal_log_init(program_invocation_short_name,
+			 internal_conf->syslog_facility) < 0) {
+		rte_eal_init_alert("Cannot init logging.");
+		rte_errno = ENOMEM;
+		rte_atomic_store_explicit(&run_once, 0, rte_memory_order_relaxed);
+		return -1;
+	}
+
 	if (rte_eal_cpu_init() < 0) {
 		rte_eal_init_alert("Cannot detect lcores.");
 		rte_errno = ENOTSUP;
@@ -1107,14 +1115,6 @@  rte_eal_init(int argc, char **argv)
 #endif
 	}
 
-	if (eal_log_init(program_invocation_short_name,
-			 internal_conf->syslog_facility) < 0) {
-		rte_eal_init_alert("Cannot init logging.");
-		rte_errno = ENOMEM;
-		rte_atomic_store_explicit(&run_once, 0, rte_memory_order_relaxed);
-		return -1;
-	}
-
 #ifdef VFIO_PRESENT
 	if (rte_eal_vfio_setup() < 0) {
 		rte_eal_init_alert("Cannot init VFIO");
diff --git a/lib/eal/unix/eal_unix_log.c b/lib/eal/unix/eal_unix_log.c
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/lib/log/log_unix.c b/lib/log/log_unix.c
index 2dfb0c974b1d..ae38b4bf3a59 100644
--- a/lib/log/log_unix.c
+++ b/lib/log/log_unix.c
@@ -41,8 +41,8 @@  static cookie_io_functions_t console_log_func = {
 };
 
 /*
- * set the log to default function, called during eal init process,
- * once memzones are available.
+ * set the log to default function, called early in eal init process;
+ * before lcore's and memzones are setup.
  */
 int
 eal_log_init(const char *id, int facility)