From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8A09745CA4; Thu, 7 Nov 2024 21:52:56 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D06E84334C; Thu, 7 Nov 2024 21:52:45 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 189D64334C for ; Thu, 7 Nov 2024 21:52:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731012764; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7A0VHcbu1aQJHgGNLZkqlXPgxN2aEe07G9Q7FyEgv0Q=; b=abxpi8OYU303TF+qxpORWpD0njT9DgVdULsk8AbBX2xGj8Lyz+9T0MvCMvsJOe55YeOvPA VOgITG5n1fbOYgBIPd/LOGYm0QcXF8P1BYTnKlDdFIhRTZSrFOfCPYLM/HpjfkYLBn56IH lghLreC9m2HcnWlm5njhaEXe5G4FqD8= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-5W1lWOR5ObODvW3ZJqaK9A-1; Thu, 07 Nov 2024 15:52:41 -0500 X-MC-Unique: 5W1lWOR5ObODvW3ZJqaK9A-1 X-Mimecast-MFC-AGG-ID: 5W1lWOR5ObODvW3ZJqaK9A Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BDDF21953956; Thu, 7 Nov 2024 20:52:39 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.57]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1EAEB1953880; Thu, 7 Nov 2024 20:52:36 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Stephen Hemminger , Tyler Retzlaff , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Bruce Richardson , Chengwen Feng , Dmitry Kozlyuk Subject: [PATCH v31 07/12] eal: initialize log before everything else Date: Thu, 7 Nov 2024 21:51:39 +0100 Message-ID: <20241107205145.2424871-8-david.marchand@redhat.com> In-Reply-To: <20241107205145.2424871-1-david.marchand@redhat.com> References: <20200814173441.23086-1-stephen@networkplumber.org> <20241107205145.2424871-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: MgqHJhBNrIQUGTyTK3MR9xjhdTYuD6uYwZl9iqAJUvk_1731012760 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Stephen Hemminger 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 Acked-by: Tyler Retzlaff Acked-by: Morten Brørup Acked-by: Bruce Richardson Acked-by: Chengwen Feng --- doc/guides/rel_notes/release_24_11.rst | 2 ++ lib/eal/freebsd/eal.c | 13 ++++++++++--- lib/eal/linux/eal.c | 14 +++++++++----- lib/eal/windows/eal.c | 10 +++++++--- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/doc/guides/rel_notes/release_24_11.rst b/doc/guides/rel_notes/release_24_11.rst index 2a78396b79..7da3c99dec 100644 --- a/doc/guides/rel_notes/release_24_11.rst +++ b/doc/guides/rel_notes/release_24_11.rst @@ -102,6 +102,8 @@ New Features * **Updated logging library** + * The log subsystem is initialized earlier in startup so all messages go through the library. + * The syslog option has changed. By default, messages are no longer sent to syslog unless the ``--syslog`` option is specified. Syslog is also supported on FreeBSD (but not on Windows). diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index a9f3efd0f0..c31a3858dd 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_parse_log_options(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); - /* parse log options as early as possible */ - eal_parse_log_options(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 2248881307..b3aae7393d 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_parse_log_options(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); - /* parse log options as early as possible */ - eal_parse_log_options(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 9bd0ab5fad..1892290f89 100644 --- a/lib/eal/windows/eal.c +++ b/lib/eal/windows/eal.c @@ -249,10 +249,14 @@ 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); + /* setup log as early as possible */ + if (eal_parse_log_options(argc, argv) < 0) { + rte_eal_init_alert("invalid log arguments."); + rte_errno = EINVAL; + return -1; + } - /* parse log options as early as possible */ - eal_parse_log_options(argc, argv); + eal_log_init(NULL); if (eal_create_cpu_map() < 0) { rte_eal_init_alert("Cannot discover CPU and NUMA."); -- 2.47.0