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 EE0D545B88; Fri, 25 Oct 2024 23:47:30 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 451B940A87; Fri, 25 Oct 2024 23:46:55 +0200 (CEST) Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by mails.dpdk.org (Postfix) with ESMTP id 4588E40674 for ; Fri, 25 Oct 2024 23:46:48 +0200 (CEST) Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-2e2e87153a3so1807703a91.3 for ; Fri, 25 Oct 2024 14:46:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1729892807; x=1730497607; 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=eS+OviVhFWsd4DhsffY/xPWiWHOp0d9y2xu8jlDFoRU=; b=MEBMObp5ZMFQcOdq+cWHKaJ0bPhNn9DzM0aDTaNa93Uui7atavmxHs5rAJICgXrmMb O4TrRK4WHCz/3EMWXSAwy4Dz9Zw5xCYR9fPhIeFzTC6+igJz4KsKBJtYqs4LrL5qHtvZ VblYT34LHxD+FH3NjoXPOamW7aJpytrjXMimkTU5RB3WHhC2R057vKJPgwd9ykKqSZwU nwLLC+qFFyE7NJDI/rNgGf0YJg8z5ZMtS9n3y4qgidoR1aASxj+/6U+EE6cLNniGXCE1 Qiw6+jggwfvSU8dU00pJWixCvH1ngeSe6xKQeQGyudWThe6D3PHvOVYPXi0hycgt7xza ZG/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729892807; x=1730497607; 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=eS+OviVhFWsd4DhsffY/xPWiWHOp0d9y2xu8jlDFoRU=; b=YXdcu+U2CEaM+XUyCC1tUboWVjy2wE8VivSdPpuPZCTX8k1tXv7TmHdYm2HXcoJokx pzi+C5mq+9vuqja42UWmVLn97A9Ms5hK9wJfj2u6Ykg0gJo4xE2HSg+Lvl2PJm82o8Mt B4Tl/sUxVHQazkTv1oMIY9cxwz8X+Qs4U+KBFXPhyj1/sC/LU+fP63NR/07SIhrm9wyX aYeUGtSViasn3fHqmwbVw/ouCwin23L5I8RT8ESNQvLEXD40Xn4I7+4sHclRe4/pr+5s 3fBvpEyK5EjTbQs9nwqjjkfF6JCq7JwZdMNKUC68VFLhDYKShAjszH8DHFBCCiuvHGdc HGsg== X-Gm-Message-State: AOJu0YwRmjLjAzl5152hTVcUSOfg+06WBbb8hzHMNcX8mUdOWKVX712n tnZG8WQvnvbxwjMT8NycWwGO8A4CEZqNx7YY3+j8QzTM13zcIgTpAGy4w7ZlzH6E0WYQnlN/2k0 k X-Google-Smtp-Source: AGHT+IF2ocIvPrmDMUl1rQAeuHCg1pfzMe5mrgEsudaADjBNALKPo8RjxwTvoJlxuGfdvF4zv57diA== X-Received: by 2002:a17:90a:e94e:b0:2e2:d1a3:faf9 with SMTP id 98e67ed59e1d1-2e8f11bbc20mr716359a91.40.1729892807384; Fri, 25 Oct 2024 14:46:47 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e77e4c9c1bsm4049934a91.19.2024.10.25.14.46.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 14:46:47 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Tyler Retzlaff , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Bruce Richardson , Chengwen Feng , Dmitry Kozlyuk Subject: [PATCH v29 08/13] eal: initialize log before everything else Date: Fri, 25 Oct 2024 14:45:13 -0700 Message-ID: <20241025214625.62876-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241025214625.62876-1-stephen@networkplumber.org> References: <20200814173441.23086-1-stephen@networkplumber.org> <20241025214625.62876-1-stephen@networkplumber.org> MIME-Version: 1.0 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 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 --- 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