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 4E06543D49; Mon, 25 Mar 2024 21:55:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DE06C40E54; Mon, 25 Mar 2024 21:54:28 +0100 (CET) Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by mails.dpdk.org (Postfix) with ESMTP id 6E8EE40DCE for ; Mon, 25 Mar 2024 21:54:24 +0100 (CET) Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-6e6b5432439so3671062b3a.1 for ; Mon, 25 Mar 2024 13:54:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1711400063; x=1712004863; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yt8sOxcACKjNMF6qKstsLWVdnhI7Desd0hXEpONxCMs=; b=p9L7cQ4KHCz/qJX+Y7DHKyrUTFU3tmS9RpV3ii8DrpEFR6MD8Em/v1E/V6klAOx+vr s/h27YPkVjOflJzhcxBS3xMO10m98RiawS1iQbDeJEHECv8y3bphKF+Nhj8VsUXF/Xz2 CfgYl5HVysPGBuw3ea+809OIkZUzae81lD4Pj4/0gkFlddSIAkAUxr6uJhw5dcWPO/tY YTJmJKQwckU6Y8Erm2J6DDpwWJYnehpS1bipqXmOFTQZacnUTKKSin1jIWyrg17Spi7e cAwn1JpigpWMQvUCVH15s7I0cM2ae7xvXIBs6sKY9XT+jDGGno5nHluJl/UmHJMMn7jZ S+5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711400063; x=1712004863; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yt8sOxcACKjNMF6qKstsLWVdnhI7Desd0hXEpONxCMs=; b=knFSzPoBh9599yUCvq77n6YgsFFygo9N5oYYIdc9Ds18n5bdbIGYj/PHxBTy7gyPRj JOG45U4dhgBSTk3I092XVV3ZqxVvNe3n28h7Ym/zAb6N2WJGTLOPD/NI9bQwD0iiO344 YsMIS8Wmymt3nx041vLYr3EGIE4Jh4NTrSjcDtyftmZP4bSKzo5RcwNmUze52znARjH/ wh39+hK+g/bPpPNCkP5tkFcQy5wrjSYqNQ0+osBAJcaUZRmSrlGHGUG41nNjuLumuiv/ f3CFZc99di39z6/Egn7uOAbW3qoF2XfujHmdX/F6eL5Uy9A8e+1KXK1E5psrbRESEW3d C3Yw== X-Gm-Message-State: AOJu0YwlquUcZq+pDji3ACXjmtQVwD59DFgo+CtLZgJkdaZHtIhgr8j9 P/6I91VglSKO75p7fz0XKnn6MMBCqZPFqGLxoyRBlGHhWvh5+CY1bhfOiSb9qixJAUypPgCr0ik O X-Google-Smtp-Source: AGHT+IEflYCd1XUvMf1BGOFNRROkOB/RJcJzohkUpsrOpVYX2SuTMgPhUq3i8q8cggS1uxI4dGUI2w== X-Received: by 2002:a05:6a20:6399:b0:1a3:5a55:bfd9 with SMTP id m25-20020a056a20639900b001a35a55bfd9mr6197218pzg.21.1711400063655; Mon, 25 Mar 2024 13:54:23 -0700 (PDT) Received: from hermes.local (204-195-123-203.wavecable.com. [204.195.123.203]) by smtp.gmail.com with ESMTPSA id b18-20020a170903229200b001e0b5eee802sm3164487plh.123.2024.03.25.13.54.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 13:54:22 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson , Dmitry Kozlyuk , Tyler Retzlaff , Pallavi Kadam Subject: [PATCH v12 07/14] eal: initialize log before everything else Date: Mon, 25 Mar 2024 13:47:04 -0700 Message-ID: <20240325205405.669897-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240325205405.669897-1-stephen@networkplumber.org> References: <20200814173441.23086-1-stephen@networkplumber.org> <20240325205405.669897-1-stephen@networkplumber.org> MIME-Version: 1.0 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 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 --- lib/eal/freebsd/eal.c | 8 +++++--- lib/eal/linux/eal.c | 15 +++++---------- lib/eal/windows/eal.c | 3 +-- lib/log/log_freebsd.c | 3 +-- lib/log/log_internal.h | 2 +- lib/log/log_linux.c | 14 ++++++-------- lib/log/log_windows.c | 4 +--- 7 files changed, 20 insertions(+), 29 deletions(-) diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index 6552f9c138..ec3a0c3244 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,10 @@ rte_eal_init(int argc, char **argv) bool has_phys_addr; enum rte_iova_mode iova_mode; + /* setup log as early as possible */ + eal_log_level_parse(argc, argv); + eal_log_init(getprogname()); + /* checks if the machine is adequate */ if (!rte_cpu_is_supported()) { rte_eal_init_alert("unsupported cpu type."); @@ -565,9 +570,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 3d0c34063e..0a488ee567 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -936,6 +936,11 @@ rte_eal_init(int argc, char **argv) struct internal_config *internal_conf = eal_get_internal_configuration(); + + /* setup log as early as possible */ + eal_log_level_parse(argc, argv); + 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."); @@ -952,9 +957,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); @@ -1106,13 +1108,6 @@ rte_eal_init(int argc, char **argv) #endif } - if (eal_log_init(program_invocation_short_name) < 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/windows/eal.c b/lib/eal/windows/eal.c index 2519a30017..fb2920e1b8 100644 --- a/lib/eal/windows/eal.c +++ b/lib/eal/windows/eal.c @@ -250,9 +250,8 @@ 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); - 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_freebsd.c b/lib/log/log_freebsd.c index 953e371bee..33a0925c43 100644 --- a/lib/log/log_freebsd.c +++ b/lib/log/log_freebsd.c @@ -5,8 +5,7 @@ #include #include "log_internal.h" -int +void eal_log_init(__rte_unused const char *id) { - return 0; } diff --git a/lib/log/log_internal.h b/lib/log/log_internal.h index cb15cdff08..d5fabd7ef7 100644 --- a/lib/log/log_internal.h +++ b/lib/log/log_internal.h @@ -14,7 +14,7 @@ * Initialize the default log stream. */ __rte_internal -int eal_log_init(const char *id); +void eal_log_init(const char *id); /* * Determine where log data is written when no call to rte_openlog_stream. diff --git a/lib/log/log_linux.c b/lib/log/log_linux.c index 47aa074da2..6d7dc8f3ab 100644 --- a/lib/log/log_linux.c +++ b/lib/log/log_linux.c @@ -87,18 +87,16 @@ static cookie_io_functions_t console_log_func = { * set the log to default function, called during eal init process, * once memzones are available. */ -int +void eal_log_init(const char *id) { FILE *log_stream; - log_stream = fopencookie(NULL, "w+", console_log_func); - if (log_stream == NULL) - return -1; - openlog(id, LOG_NDELAY | LOG_PID, log_facility); - eal_log_set_default(log_stream); - - return 0; + log_stream = fopencookie(NULL, "w+", console_log_func); + if (log_stream != NULL) + eal_log_set_default(log_stream); + else + eal_log_set_default(stderr); } diff --git a/lib/log/log_windows.c b/lib/log/log_windows.c index a3a756351d..d7c30e4cfa 100644 --- a/lib/log/log_windows.c +++ b/lib/log/log_windows.c @@ -13,12 +13,10 @@ eal_log_syslog(const char *name __rte_unused) } /* set the log to default function, called during eal init process. */ -int +void eal_log_init(__rte_unused const char *id) { rte_openlog_stream(stderr); eal_log_set_default(stderr); - - return 0; } -- 2.43.0