From patchwork Mon Mar 18 18:30:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 138466 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2F64643CE8; Mon, 18 Mar 2024 19:32:52 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B3D7B40696; Mon, 18 Mar 2024 19:32:47 +0100 (CET) Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by mails.dpdk.org (Postfix) with ESMTP id BA7634027F for ; Mon, 18 Mar 2024 19:32:45 +0100 (CET) Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-6e6afb754fcso4438294b3a.3 for ; Mon, 18 Mar 2024 11:32:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1710786765; x=1711391565; 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=37akOt+01Du3dsCF3OJ9MabMFuRbj1LJQ50GxELecLs=; b=zsafVJNRIj1QccTrzoa7q6pIABVnSo5/iuMkYO+yvAd33Di2VTHRxtmF2weVMjVYxa RQiYzoryiwg7Fg/67p01FPDfAON2jCRN/mtiz3kx0PnyrtI3aX1GAexo09JjFMrduaRm JZ1RwFNY/PzIJihsal7cbuksYZBqThU63yCSN4KEEzuayzdncqr6Yu2mx2fhA65NfIIS GbTBvdGT8lvPrQ+CdzXltbyKwVgnPC3PIfGMXRCbLKV52SftYuUxBV2Yv48IEKTiNJOS Y5XFXcPflq7ICPXGqb1dDH/epCuedf7xUMXEHH2B/ecE9Ztzen9kNU5Xw5iRv3XUxNhB 8BDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710786765; x=1711391565; 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=37akOt+01Du3dsCF3OJ9MabMFuRbj1LJQ50GxELecLs=; b=PeI5m9LRREyZqS3om4hQnOGwveiQq2roBmPx+OIuYYzmTYNketqh4jM2XKwB/r3kKP eBEBDEhjmzK7AG9xzibQXVmBJusuPdLetoe6GjOkP1b/Fz6E4dm8goJvCpqy/ocvx1Sh fpSSO46u49uTD/aD7KOpQgT53DnNGCAXi2lrV4VYlaNyzRCsKtJKMhLkUYGpLNSjdBWk EoXmGJIcsMHUUedVQdOWi/wp9hgi94fD22yUStd90R8osmarFNG/8spB1U2eDvOtrhaq rvhj82Q3xpE2YqWIZLJzJVusC53FMCoETzusoyg8jiztpBsLT9EpomKn+leE0o7d8iZm TinA== X-Gm-Message-State: AOJu0Yz7sXIDxnQzMq5Mz6YEf29VntTvR/puWZ9uaCCA1TrEUe4gnmF8 vOYluEQ2ADHLgkNGdlXxfSKbcL8eusRVbY0KQAxdPAnTr2FXTRMf+hqv2PewAjQw2eUW1WlFynE B X-Google-Smtp-Source: AGHT+IHy4f1M9mw7xzAqGFH+JHcHavXidNSJ009rlTCsMpThlWctkRgBt+BqM/wNM7TcQGBRjXXhgw== X-Received: by 2002:a05:6a00:847:b0:6e6:4f67:8440 with SMTP id q7-20020a056a00084700b006e64f678440mr15786680pfk.1.1710786764720; Mon, 18 Mar 2024 11:32:44 -0700 (PDT) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id x6-20020aa784c6000000b006e4e93f4f17sm8186593pfn.117.2024.03.18.11.32.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 11:32:44 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v8 1/5] log: unify logging code Date: Mon, 18 Mar 2024 11:30:02 -0700 Message-ID: <20240318183233.142330-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240318183233.142330-1-stephen@networkplumber.org> References: <20200814173441.23086-1-stephen@networkplumber.org> <20240318183233.142330-1-stephen@networkplumber.org> MIME-Version: 1.0 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 FreeBSD and Linux logging code can use common code. This also fixes FreeBSD not using syslog. Signed-off-by: Stephen Hemminger --- doc/guides/linux_gsg/linux_eal_parameters.rst | 27 ------------------- doc/guides/prog_guide/log_lib.rst | 18 +++++++++++-- lib/eal/freebsd/eal.c | 8 ++++++ lib/log/log_freebsd.c | 12 --------- lib/log/{log_linux.c => log_unix.c} | 0 lib/log/meson.build | 12 ++++++--- 6 files changed, 32 insertions(+), 45 deletions(-) delete mode 100644 lib/log/log_freebsd.c rename lib/log/{log_linux.c => log_unix.c} (100%) diff --git a/doc/guides/linux_gsg/linux_eal_parameters.rst b/doc/guides/linux_gsg/linux_eal_parameters.rst index ea8f38139119..d86f94d8a85d 100644 --- a/doc/guides/linux_gsg/linux_eal_parameters.rst +++ b/doc/guides/linux_gsg/linux_eal_parameters.rst @@ -108,30 +108,3 @@ Memory-related options * ``--match-allocations`` Free hugepages back to system exactly as they were originally allocated. - -Other options -~~~~~~~~~~~~~ - -* ``--syslog `` - - Set syslog facility. Valid syslog facilities are:: - - auth - cron - daemon - ftp - kern - lpr - mail - news - syslog - user - uucp - local0 - local1 - local2 - local3 - local4 - local5 - local6 - local7 diff --git a/doc/guides/prog_guide/log_lib.rst b/doc/guides/prog_guide/log_lib.rst index ff9d1b54a2c8..aacb36c36ce0 100644 --- a/doc/guides/prog_guide/log_lib.rst +++ b/doc/guides/prog_guide/log_lib.rst @@ -5,8 +5,8 @@ Log Library =========== The DPDK Log library provides the logging functionality for other DPDK libraries and drivers. -By default, in a Linux application, logs are sent to syslog and also to the console. -On FreeBSD and Windows applications, logs are sent only to the console. +By default, in a Linux (or FreeBSD) application, logs are sent to syslog and also to the console. +In Windows applications, logs are sent only to the console. However, the log function can be overridden by the user to use a different logging mechanism. Log Levels @@ -29,6 +29,7 @@ will be emitted by the application to the log output. That level can be configured either by the application calling the relevant APIs from the logging library, or by the user passing the ``--log-level`` parameter to the EAL via the application. + Setting Global Log Level ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -59,6 +60,19 @@ For example:: Within an application, the same result can be got using the ``rte_log_set_level_pattern()`` or ``rte_log_set_level_regex()`` APIs. + +Setting syslog facility +~~~~~~~~~~~~~~~~~~~~~~~ + +On Linux and FreeBSD, where syslog is used a ``facility`` argument can be +used to specify what type of program is logging. +The default facility is ``daemon`` but it can be overridden +by the ``--syslog`` EAL parameter. See ``syslog.3`` man page for full values. +For example:: + + /path/to/app --syslog local0 + + Using Logging APIs to Generate Log Messages ------------------------------------------- diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index bab77118e967..004b8fad2db3 100644 --- a/lib/eal/freebsd/eal.c +++ b/lib/eal/freebsd/eal.c @@ -760,6 +760,14 @@ 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; + } + /* 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/log/log_freebsd.c b/lib/log/log_freebsd.c deleted file mode 100644 index 698d3c542337..000000000000 --- a/lib/log/log_freebsd.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2023 Intel Corporation - */ - -#include -#include "log_internal.h" - -int -eal_log_init(__rte_unused const char *id, __rte_unused int facility) -{ - return 0; -} diff --git a/lib/log/log_linux.c b/lib/log/log_unix.c similarity index 100% rename from lib/log/log_linux.c rename to lib/log/log_unix.c diff --git a/lib/log/meson.build b/lib/log/meson.build index 0d4319b36f77..60516a0b2a2d 100644 --- a/lib/log/meson.build +++ b/lib/log/meson.build @@ -2,8 +2,12 @@ # Copyright(c) 2023 Intel Corporation includes += global_inc -sources = files( - 'log.c', - 'log_' + exec_env + '.c', -) +sources = files('log.c') + +if is_windows + sources += files('log_windows.c') +else + sources += files('log_unix.c') +endif + headers = files('rte_log.h') From patchwork Mon Mar 18 18:30:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 138467 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E7D2343CE8; Mon, 18 Mar 2024 19:33:00 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 78A7740A70; Mon, 18 Mar 2024 19:32:49 +0100 (CET) Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by mails.dpdk.org (Postfix) with ESMTP id 8E38D4067C for ; Mon, 18 Mar 2024 19:32:46 +0100 (CET) Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-6e6aaa2f02cso3602642b3a.2 for ; Mon, 18 Mar 2024 11:32:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1710786765; x=1711391565; 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=BtOSUjwZ/lu5nGukLQF0wUztmZUtU0wwHFD7PQ+xr3c=; b=I1bpA7qIUk85QpBpRDCKbySSWMf/aWCSQHs0fE/CuAIlnrI/nJA7CBtdIVKhLRLnot kKtVq2XxdRstbxKew91KOYDifCLFuUhgDNRNPVHDe1x1QddJ7WyvYgTcQiHb7rUUn+Sw Ci4xIN3z0Ydg08+5RqWhjItoszYn7FLXKI/7x4zafRdNHTIR+SyI4wwJpTIuYi+hKIrL dpenrmw2j7DaS14gHoN2S915FEmialkGcuIX6R0+YXTkeimDgaiektw3tnxoRvgpD/az /rtqbj+B8XT+OP/j8oxSL9o+HyO2bp84AISoXCnUtipda+DU80Z9LFgZUMIZh+aJixZv U+/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710786765; x=1711391565; 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=BtOSUjwZ/lu5nGukLQF0wUztmZUtU0wwHFD7PQ+xr3c=; b=YTP/CMB1CXFrq5xO287vJfLyMLmiELRcGefG2od+1812RUwSj9I5+kr/amCHeMonlq 7WUABJEk4MN6peqSosKP8mgmpOTHel/cwAvPTIAbH86d88IvXxQukbqKVvADWvx91cAX 7m5PQtPpTgT46MDlmQfxFDxOtWdZDe4wCfjrvETDZvQ0H+5iOfJjOkHAx4Rtbn+nWWKz aC3ggTFHNAg0vjZq/q/IT042RRqSwllSoHqBvvjFt6VOe3zuCpLjMy4QQHJEzVKiqgLm WFL77305jsjEfsmMiROyiRhEcbfNZYf9Ca3yIEot6a0A5U5qGf9iPJrn4VH/q3tzlZTs o0BQ== X-Gm-Message-State: AOJu0Yz4mBZ0bYPS2w0KhLa0gr1tA7hX2vW0iLq1MlSBlWtHyjYntp/8 2RCLXfjgcrSWjIqAexVPEL8Ob1onTCuTdulf3VDQt5wBv9W/t5Dafld3M10RxMjvnGmDVjZbMTm I X-Google-Smtp-Source: AGHT+IHw9cTvnRIzu6JjYk4P3X1MT0NRESVVYlsRCuP3XvsklRT06YqfEtIZNFUujN+Vhkzh9Gi1qg== X-Received: by 2002:a05:6a00:2389:b0:6e6:e587:3c39 with SMTP id f9-20020a056a00238900b006e6e5873c39mr553888pfc.24.1710786765455; Mon, 18 Mar 2024 11:32:45 -0700 (PDT) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id x6-20020aa784c6000000b006e4e93f4f17sm8186593pfn.117.2024.03.18.11.32.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 11:32:45 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v8 2/5] eal: make eal_log_level_parse common Date: Mon, 18 Mar 2024 11:30:03 -0700 Message-ID: <20240318183233.142330-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240318183233.142330-1-stephen@networkplumber.org> References: <20200814173441.23086-1-stephen@networkplumber.org> <20240318183233.142330-1-stephen@networkplumber.org> MIME-Version: 1.0 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 The code to parse for log-level option should be same on all OS variants. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_options.c | 46 +++++++++++++++++++++++++++++ lib/eal/common/eal_options.h | 1 + lib/eal/freebsd/eal.c | 42 -------------------------- lib/eal/linux/eal.c | 39 ------------------------ lib/eal/windows/eal.c | 35 ---------------------- 5 files changed, 47 insertions(+), 116 deletions(-) diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c index e541f0793964..7310d10dfd78 100644 --- a/lib/eal/common/eal_common_options.c +++ b/lib/eal/common/eal_common_options.c @@ -1640,6 +1640,51 @@ eal_parse_huge_unlink(const char *arg, struct hugepage_file_discipline *out) return -1; } +/* Parse the all arguments looking for --log-level */ +int +eal_log_level_parse(int argc, char * const argv[]) +{ + struct internal_config *internal_conf = eal_get_internal_configuration(); + int option_index, opt; + const int old_optind = optind; + const int old_optopt = optopt; + const int old_opterr = opterr; + char *old_optarg = optarg; +#ifdef RTE_EXEC_ENV_FREEBSD + const int old_optreset = optreset; + optreset = 1; +#endif + + optind = 1; + opterr = 0; + + while ((opt = getopt_long(argc, argv, eal_short_options, + eal_long_options, &option_index)) != EOF) { + + switch (opt) { + case OPT_LOG_LEVEL_NUM: + if (eal_parse_common_option(opt, optarg, internal_conf) < 0) + return -1; + break; + case '?': + /* getopt is not happy, stop right now */ + goto out; + default: + continue; + } + } +out: + /* restore getopt lib */ + optind = old_optind; + optopt = old_optopt; + optarg = old_optarg; + opterr = old_opterr; +#ifdef RTE_EXEC_ENV_FREEBSD + optreset = old_optreset; +#endif + return 0; +} + int eal_parse_common_option(int opt, const char *optarg, struct internal_config *conf) @@ -2173,6 +2218,7 @@ rte_vect_set_max_simd_bitwidth(uint16_t bitwidth) return 0; } + void eal_common_usage(void) { diff --git a/lib/eal/common/eal_options.h b/lib/eal/common/eal_options.h index 3cc9cb641284..f3f2e104f6d7 100644 --- a/lib/eal/common/eal_options.h +++ b/lib/eal/common/eal_options.h @@ -96,6 +96,7 @@ enum { extern const char eal_short_options[]; extern const struct option eal_long_options[]; +int eal_log_level_parse(int argc, char * const argv[]); int eal_parse_common_option(int opt, const char *argv, struct internal_config *conf); int eal_option_device_parse(void); diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index 004b8fad2db3..b4f8d68b0a65 100644 --- a/lib/eal/freebsd/eal.c +++ b/lib/eal/freebsd/eal.c @@ -363,48 +363,6 @@ eal_get_hugepage_mem_size(void) return (size < SIZE_MAX) ? (size_t)(size) : SIZE_MAX; } -/* Parse the arguments for --log-level only */ -static void -eal_log_level_parse(int argc, char **argv) -{ - int opt; - char **argvopt; - int option_index; - const int old_optind = optind; - const int old_optopt = optopt; - const int old_optreset = optreset; - char * const old_optarg = optarg; - struct internal_config *internal_conf = - eal_get_internal_configuration(); - - argvopt = argv; - optind = 1; - optreset = 1; - - while ((opt = getopt_long(argc, argvopt, eal_short_options, - eal_long_options, &option_index)) != EOF) { - - int ret; - - /* getopt is not happy, stop right now */ - if (opt == '?') - break; - - ret = (opt == OPT_LOG_LEVEL_NUM) ? - eal_parse_common_option(opt, optarg, internal_conf) : 0; - - /* common parser is not happy */ - if (ret < 0) - break; - } - - /* restore getopt lib */ - optind = old_optind; - optopt = old_optopt; - optreset = old_optreset; - optarg = old_optarg; -} - /* Parse the argument given in the command line of the application */ static int eal_parse_args(int argc, char **argv) diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index fd422f1f6236..bffeb1f34eb9 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -546,45 +546,6 @@ eal_parse_vfio_vf_token(const char *vf_token) return -1; } -/* Parse the arguments for --log-level only */ -static void -eal_log_level_parse(int argc, char **argv) -{ - int opt; - char **argvopt; - int option_index; - const int old_optind = optind; - const int old_optopt = optopt; - char * const old_optarg = optarg; - struct internal_config *internal_conf = - eal_get_internal_configuration(); - - argvopt = argv; - optind = 1; - - while ((opt = getopt_long(argc, argvopt, eal_short_options, - eal_long_options, &option_index)) != EOF) { - - int ret; - - /* getopt is not happy, stop right now */ - if (opt == '?') - break; - - ret = (opt == OPT_LOG_LEVEL_NUM) ? - eal_parse_common_option(opt, optarg, internal_conf) : 0; - - /* common parser is not happy */ - if (ret < 0) - break; - } - - /* restore getopt lib */ - optind = old_optind; - optopt = old_optopt; - optarg = old_optarg; -} - static int eal_parse_huge_worker_stack(const char *arg) { diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c index 52f0e7462dd8..85171b27687e 100644 --- a/lib/eal/windows/eal.c +++ b/lib/eal/windows/eal.c @@ -96,41 +96,6 @@ eal_usage(const char *prgname) } } -/* Parse the arguments for --log-level only */ -static void -eal_log_level_parse(int argc, char **argv) -{ - int opt; - char **argvopt; - int option_index; - struct internal_config *internal_conf = - eal_get_internal_configuration(); - - argvopt = argv; - - eal_reset_internal_config(internal_conf); - - while ((opt = getopt_long(argc, argvopt, eal_short_options, - eal_long_options, &option_index)) != EOF) { - - int ret; - - /* getopt is not happy, stop right now */ - if (opt == '?') - break; - - ret = (opt == OPT_LOG_LEVEL_NUM) ? - eal_parse_common_option(opt, optarg, - internal_conf) : 0; - - /* common parser is not happy */ - if (ret < 0) - break; - } - - optind = 0; /* reset getopt lib */ -} - /* Parse the argument given in the command line of the application */ static int eal_parse_args(int argc, char **argv) From patchwork Mon Mar 18 18:30:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 138468 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DFD7743CE8; Mon, 18 Mar 2024 19:33:07 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CBAE7406BA; Mon, 18 Mar 2024 19:32:51 +0100 (CET) Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) by mails.dpdk.org (Postfix) with ESMTP id 435034068E for ; Mon, 18 Mar 2024 19:32:47 +0100 (CET) Received: by mail-oi1-f176.google.com with SMTP id 5614622812f47-3c36f882372so2784894b6e.2 for ; Mon, 18 Mar 2024 11:32:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1710786766; x=1711391566; 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=T8d4wbz8UaPAWAX98FuZk1eIKsZOb9m1Xynp/hHjNCo=; b=1zvT9yoUij2iTIpCIkxlG7tMR3b6oO9O8DmBQqU6QU+V2lC70Zr2clta3c1zsRjrdF BN0L7bDdg7fCSSqv9xq0fXSv+Vl1SENXrQqjmF0MZaKJ6ISm9Gpv5hqRqS0W7nZegNRR vcD8DvfukUfo/iCoRJIQfysE07B3o3Qj+pptWI/etiwFFh4A9EX78guFvo61fy+gIyC7 qwj+MK1nzgEmXRWoJlzLFrNqrHStl/2K58/WluFANYvOjMmtcwAsBbIhmjLE8gPLnO6T QjjErU9aGRVwEI8BO5wl73/UzbZhnMcAJkg76OJAGHy0WM0y9unzEapSpEXjWRKNoy/B 1qvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710786766; x=1711391566; 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=T8d4wbz8UaPAWAX98FuZk1eIKsZOb9m1Xynp/hHjNCo=; b=N9cL5pLzRxotaGIKRBAAkBRuAQjXwu6mXurx/mpL8LSZNoQHxGEypeYBDCZJaiFtQC /sE1Jf+2ElqRR1Z+Bo9Y1nAFVQWHVA1HQkCH/Qlu8uFq5HhcRTIEzlU7Y1bSm4bIqrKq 2FBdwnslj559ckGl0bRquwDeaWQWRzmR45D6N/qH+dswRHNGvdOjVct9x6CQWJvyj0aC XgIcmVKkhOtq3SfY4VDskcGUa+MxyTnX6t0ISe3T+NhIN6GWm4K71v1eCEIE6vmE2PYh y4kKoz8/PQNiv360+KPt7LYQi2Ts1MD8tq5pXO4xoEr+gthSpnKxscVW/mQDUGYiRdMA W13g== X-Gm-Message-State: AOJu0Yx7SezZW1fHTrGYLI6uPb5Vsnmyjv8gJB8vRkDCt1sv8K2AmzrI GTdo/GfC9HHlMIzCVOAqYHtLwKoFhaavsyU4rvv5ewcc8O/R3E4aEBmlMKoPpuC2hRzXcK284zG p X-Google-Smtp-Source: AGHT+IH3DdFj1CfRK61NakMoFGaOT7Cmx4WIlq353GccR+8jc8XIwGJr83I7aHR4CNPYYC3lMr0dhg== X-Received: by 2002:a05:6358:528c:b0:17e:a952:2c00 with SMTP id g12-20020a056358528c00b0017ea9522c00mr529398rwa.4.1710786766473; Mon, 18 Mar 2024 11:32:46 -0700 (PDT) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id x6-20020aa784c6000000b006e4e93f4f17sm8186593pfn.117.2024.03.18.11.32.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 11:32:45 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v8 3/5] eal: allow user to set default log stream before init Date: Mon, 18 Mar 2024 11:30:04 -0700 Message-ID: <20240318183233.142330-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240318183233.142330-1-stephen@networkplumber.org> References: <20200814173441.23086-1-stephen@networkplumber.org> <20240318183233.142330-1-stephen@networkplumber.org> MIME-Version: 1.0 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 It is useful for application to be able to set the default log stream before call rte_eal_init(). This makes all messages go to the new default. For example, to skip using syslog; just doing rte_openlog_stream(stderr); There is no reason for helper command line applications to clutter syslog with messages. Signed-off-by: Stephen Hemminger --- app/dumpcap/main.c | 3 +++ app/pdump/main.c | 3 +++ app/proc-info/main.c | 3 +++ lib/log/log.c | 6 ++++++ lib/log/log_internal.h | 2 ++ lib/log/log_unix.c | 4 ++++ lib/log/version.map | 1 + 7 files changed, 22 insertions(+) diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c index cc0f66b2bc61..27934ca7e688 100644 --- a/app/dumpcap/main.c +++ b/app/dumpcap/main.c @@ -633,6 +633,9 @@ static void dpdk_init(void) rte_panic("No memory\n"); } + /* keep any logging away from syslog. */ + rte_openlog_stream(stderr); + if (rte_eal_init(eal_argc, eal_argv) < 0) rte_exit(EXIT_FAILURE, "EAL init failed: is primary process running?\n"); } diff --git a/app/pdump/main.c b/app/pdump/main.c index a9205e130bb1..7b9ba68b1a14 100644 --- a/app/pdump/main.c +++ b/app/pdump/main.c @@ -995,6 +995,9 @@ main(int argc, char **argv) argc += 2; + /* keep any logging away from syslog. */ + rte_openlog_stream(stderr); + diag = rte_eal_init(argc, argp); if (diag < 0) rte_panic("Cannot init EAL\n"); diff --git a/app/proc-info/main.c b/app/proc-info/main.c index b672aaefbe99..24ee52c4ac7a 100644 --- a/app/proc-info/main.c +++ b/app/proc-info/main.c @@ -2149,6 +2149,9 @@ main(int argc, char **argv) argc += 4; + /* keep any logging away from syslog. */ + rte_openlog_stream(stderr); + ret = rte_eal_init(argc, argp); if (ret < 0) rte_panic("Cannot init EAL\n"); diff --git a/lib/log/log.c b/lib/log/log.c index 255f757d94cc..4cc944305057 100644 --- a/lib/log/log.c +++ b/lib/log/log.c @@ -519,6 +519,12 @@ eal_log_set_default(FILE *default_log) #endif } +FILE * +eal_log_get_default(void) +{ + return default_log_stream; +} + /* * Called by eal_cleanup */ diff --git a/lib/log/log_internal.h b/lib/log/log_internal.h index 451629f1c1ba..c77e687e28bc 100644 --- a/lib/log/log_internal.h +++ b/lib/log/log_internal.h @@ -21,6 +21,8 @@ int eal_log_init(const char *id, int facility); */ __rte_internal void eal_log_set_default(FILE *default_log); +__rte_internal +FILE *eal_log_get_default(void); /* * Save a log option for later. diff --git a/lib/log/log_unix.c b/lib/log/log_unix.c index 2dfb0c974b1d..a415bae5774d 100644 --- a/lib/log/log_unix.c +++ b/lib/log/log_unix.c @@ -49,6 +49,10 @@ eal_log_init(const char *id, int facility) { FILE *log_stream; + /* skip if user has already setup a log stream */ + if (eal_log_get_default()) + return 0; + log_stream = fopencookie(NULL, "w+", console_log_func); if (log_stream == NULL) return -1; diff --git a/lib/log/version.map b/lib/log/version.map index 0648f8831aff..6ecc656d1d65 100644 --- a/lib/log/version.map +++ b/lib/log/version.map @@ -25,6 +25,7 @@ DPDK_24 { INTERNAL { global: + eal_log_get_default; eal_log_init; eal_log_level2str; eal_log_save_pattern; From patchwork Mon Mar 18 18:30:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 138469 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 03CFE43CE8; Mon, 18 Mar 2024 19:33:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 32F0B40A79; Mon, 18 Mar 2024 19:32:53 +0100 (CET) Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by mails.dpdk.org (Postfix) with ESMTP id 5D72E406A2 for ; Mon, 18 Mar 2024 19:32:48 +0100 (CET) Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-6e6ca2ac094so4266147b3a.0 for ; Mon, 18 Mar 2024 11:32:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1710786767; x=1711391567; 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=mm+yD9goF61yhxXIeT7u6e0EGZS37olmLkVeOSQvEYg=; b=VVawW5vydty+MDUacFMppxrfCQyct94gJpc3HxCgBxnfFKE3skNSsj9i4Z551587/W XpPWLwDmkTHi9+xsE6mTgytBhIaASD4laIlZAN++eHjX2m3a+/Qkg2k+VSwyJVWDXmiM OBNVO9QGrJ8Oi9QyInFV6X3hPUVZjWpdzjpqEko2tOHmOEnUH9RWk4szQiIgO0wvo9yp FS+u4oOkkLFdHFcL9AqjEAX2AAVwtKwXqK2ZU0gMN0mliCTOKuOGxaMrwc0uV1tg8aUz 9xUwXAKsvK2yf879MaGZcJQ9SR3Iqz6g0tmlQZtH1aWHgOuPDEHiXhg6Ei2Wu7Db4QUo 5/OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710786767; x=1711391567; 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=mm+yD9goF61yhxXIeT7u6e0EGZS37olmLkVeOSQvEYg=; b=pwjrhUkOc/J+fjazZaRlg3WBlSo/tIp+3dqdAlzm2NmwnKJhZOGtj6Mue3B1LB46uB 61aGO4nJaLHQAkukrcBFIvz523J6+mQLUeoCK1GRiL0miJ1i5n07ljxyabYxYEfuU7qZ GkuUhaaXz9/UmrikXREstLtH9UHpIXWUZhvsrH1jqMG/rjXh7KfGnPH4uQKCXIWN6XQI cAUwb7DP+wWoMH3mLoVr2xGOrEHb0/Qz54jE5vpi/9NxMkCOLS7DU4K5RCqDLEcVDePM TBo/Q6SPV9wro2d00UpTU+cO2Am3oV+kE0s4KIydexsrCfkTlf3DJgXW2JnnUCWfLrnV 3hIg== X-Gm-Message-State: AOJu0YwzeL97ZOLgH8FUN6xVCH+J7U3QGmPIvm5babf2CvvckdmipplV 9CfkqIOHCbyRFdBXneDE8CCH15WdT13CHnVACEBGqu3hYPNdzG0anDGaDabGXnzPINYmQz8BTtw X X-Google-Smtp-Source: AGHT+IEBNJNHMiSovK/hg/kCczFPji7pZ86SRmPGD/2RMJauqxYFCXlNg+ci69QVNIh/BiWqmzUz6Q== X-Received: by 2002:a05:6a00:3d4d:b0:6e6:269d:1a38 with SMTP id lp13-20020a056a003d4d00b006e6269d1a38mr569673pfb.25.1710786767527; Mon, 18 Mar 2024 11:32:47 -0700 (PDT) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id x6-20020aa784c6000000b006e4e93f4f17sm8186593pfn.117.2024.03.18.11.32.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 11:32:46 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v8 4/5] eal: add option to put timestamp on console output Date: Mon, 18 Mar 2024 11:30:05 -0700 Message-ID: <20240318183233.142330-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240318183233.142330-1-stephen@networkplumber.org> References: <20200814173441.23086-1-stephen@networkplumber.org> <20240318183233.142330-1-stephen@networkplumber.org> MIME-Version: 1.0 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 When debugging driver or startup issues, it is useful to have a timestamp on each message printed. The messages in syslog already have a timestamp, but often syslog is not available during testing. The timestamp format is chosen to look like the default Linux dmesg timestamp. The first few lines are not timestamped because the flag is stored in internal configuration which is stored in shared memory which is not setup up until a little later in startup process. This logging skips the unnecessary step of going through stdio, which makes it more robust against being called in interrupt handlers etc. Example: $ dpdk-testpmd --log-timestamp -- -i EAL: Detected CPU lcores: 16 EAL: Detected NUMA nodes: 1 EAL: Detected static linkage of DPDK EAL: Multi-process socket /var/run/dpdk/rte/mp_socket EAL: Selected IOVA mode 'VA' [ 0.112264] testpmd: No probed ethernet devices Interactive-mode selected [ 0.184573] testpmd: create a new mbuf pool : n=163456, size=2176, socket=0 [ 0.184612] testpmd: preferred mempool ops selected: ring_mp_mc Signed-off-by: Stephen Hemminger --- app/test/test_eal_flags.c | 9 ++++++++ doc/guides/prog_guide/log_lib.rst | 10 +++++++++ lib/eal/common/eal_common_options.c | 10 +++++++-- lib/eal/common/eal_options.h | 2 ++ lib/log/log_internal.h | 9 ++++++++ lib/log/log_unix.c | 32 +++++++++++++++++++++++++++-- lib/log/log_windows.c | 6 ++++++ lib/log/version.map | 1 + 8 files changed, 75 insertions(+), 4 deletions(-) diff --git a/app/test/test_eal_flags.c b/app/test/test_eal_flags.c index 6cb4b0675730..07a038fb6051 100644 --- a/app/test/test_eal_flags.c +++ b/app/test/test_eal_flags.c @@ -1055,6 +1055,10 @@ test_misc_flags(void) const char * const argv22[] = {prgname, prefix, mp_flag, "--huge-worker-stack=512"}; + /* Try running with --log-timestamp */ + const char * const argv23[] = {prgname, prefix, mp_flag, + "--log-timestamp" }; + /* run all tests also applicable to FreeBSD first */ if (launch_proc(argv0) == 0) { @@ -1162,6 +1166,11 @@ test_misc_flags(void) printf("Error - process did not run ok with --huge-worker-stack=size parameter\n"); goto fail; } + if (launch_proc(argv23) != 0) { + printf("Error - process did not run ok with --log-timestamp parameter\n"); + goto fail; + } + rmdir(hugepath_dir3); rmdir(hugepath_dir2); diff --git a/doc/guides/prog_guide/log_lib.rst b/doc/guides/prog_guide/log_lib.rst index aacb36c36ce0..1d6b2e3cea5d 100644 --- a/doc/guides/prog_guide/log_lib.rst +++ b/doc/guides/prog_guide/log_lib.rst @@ -73,6 +73,16 @@ For example:: /path/to/app --syslog local0 +Console timestamp +~~~~~~~~~~~~~~~~~ + +On Linux and FreeBSD, an optional timestamp can be added before each +message by adding the ``--log-timestamp`` option. +For example:: + + /path/to/app --log-level=lib.*:debug --log-timestamp + + Using Logging APIs to Generate Log Messages ------------------------------------------- diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c index 7310d10dfd78..9bc95433d27c 100644 --- a/lib/eal/common/eal_common_options.c +++ b/lib/eal/common/eal_common_options.c @@ -77,6 +77,7 @@ eal_long_options[] = { {OPT_IOVA_MODE, 1, NULL, OPT_IOVA_MODE_NUM }, {OPT_LCORES, 1, NULL, OPT_LCORES_NUM }, {OPT_LOG_LEVEL, 1, NULL, OPT_LOG_LEVEL_NUM }, + {OPT_LOG_TIMESTAMP, 0, NULL, OPT_LOG_TIMESTAMP_NUM }, {OPT_TRACE, 1, NULL, OPT_TRACE_NUM }, {OPT_TRACE_DIR, 1, NULL, OPT_TRACE_DIR_NUM }, {OPT_TRACE_BUF_SIZE, 1, NULL, OPT_TRACE_BUF_SIZE_NUM }, @@ -1663,6 +1664,7 @@ eal_log_level_parse(int argc, char * const argv[]) switch (opt) { case OPT_LOG_LEVEL_NUM: + case OPT_LOG_TIMESTAMP_NUM: if (eal_parse_common_option(opt, optarg, internal_conf) < 0) return -1; break; @@ -1890,7 +1892,7 @@ eal_parse_common_option(int opt, const char *optarg, break; #endif - case OPT_LOG_LEVEL_NUM: { + case OPT_LOG_LEVEL_NUM: if (eal_parse_log_level(optarg) < 0) { EAL_LOG(ERR, "invalid parameters for --" @@ -1898,7 +1900,10 @@ eal_parse_common_option(int opt, const char *optarg, return -1; } break; - } + + case OPT_LOG_TIMESTAMP_NUM: + eal_log_enable_timestamp(); + break; #ifndef RTE_EXEC_ENV_WINDOWS case OPT_TRACE_NUM: { @@ -2261,6 +2266,7 @@ eal_common_usage(void) " --"OPT_PROC_TYPE" Type of this process (primary|secondary|auto)\n" #ifndef RTE_EXEC_ENV_WINDOWS " --"OPT_SYSLOG" Set syslog facility\n" + " --"OPT_LOG_TIMESTAMP" Timestamp log output\n" #endif " --"OPT_LOG_LEVEL"= Set global log level\n" " --"OPT_LOG_LEVEL"=:\n" diff --git a/lib/eal/common/eal_options.h b/lib/eal/common/eal_options.h index f3f2e104f6d7..e24c9eca53ca 100644 --- a/lib/eal/common/eal_options.h +++ b/lib/eal/common/eal_options.h @@ -35,6 +35,8 @@ enum { OPT_LCORES_NUM, #define OPT_LOG_LEVEL "log-level" OPT_LOG_LEVEL_NUM, +#define OPT_LOG_TIMESTAMP "log-timestamp" + OPT_LOG_TIMESTAMP_NUM, #define OPT_TRACE "trace" OPT_TRACE_NUM, #define OPT_TRACE_DIR "trace-dir" diff --git a/lib/log/log_internal.h b/lib/log/log_internal.h index c77e687e28bc..1af27fe8f9d3 100644 --- a/lib/log/log_internal.h +++ b/lib/log/log_internal.h @@ -5,8 +5,10 @@ #ifndef LOG_INTERNAL_H #define LOG_INTERNAL_H +#include #include #include +#include #include @@ -44,4 +46,11 @@ const char *eal_log_level2str(uint32_t level); __rte_internal void rte_eal_log_cleanup(void); +/* + * Add timestamp to console logs + */ +__rte_internal +void eal_log_enable_timestamp(void); + + #endif /* LOG_INTERNAL_H */ diff --git a/lib/log/log_unix.c b/lib/log/log_unix.c index a415bae5774d..71ce366b6825 100644 --- a/lib/log/log_unix.c +++ b/lib/log/log_unix.c @@ -2,24 +2,52 @@ * Copyright(c) 2010-2014 Intel Corporation */ +#include #include #include +#include #include +#include +#include #include #include "log_internal.h" +static bool timestamp_enabled; +static struct timespec log_started; + +void +eal_log_enable_timestamp(void) +{ + timestamp_enabled = true; + clock_gettime(CLOCK_MONOTONIC, &log_started); +} + /* * default log function */ static ssize_t console_log_write(__rte_unused void *c, const char *buf, size_t size) { + struct timespec ts; ssize_t ret; - /* write on stderr */ - ret = fwrite(buf, 1, size, stderr); + if (timestamp_enabled) { + clock_gettime(CLOCK_MONOTONIC, &ts); + ts.tv_sec -= log_started.tv_sec; + ts.tv_nsec -= log_started.tv_nsec; + if (ts.tv_nsec < 0) { + --ts.tv_sec; + ts.tv_nsec += 1000000000ul; + } + + ret = fprintf(stderr, "[%8lu.%06lu] %.*s", + ts.tv_sec, ts.tv_nsec / 1000u, + (int) size, buf); + } else { + ret = fwrite(buf, 1, size, stderr); + } fflush(stderr); /* Syslog error levels are from 0 to 7, so subtract 1 to convert */ diff --git a/lib/log/log_windows.c b/lib/log/log_windows.c index a6a08895501e..0c471bfb15f6 100644 --- a/lib/log/log_windows.c +++ b/lib/log/log_windows.c @@ -6,6 +6,12 @@ #include #include "log_internal.h" +void +eal_log_enable_timestamp(void) +{ + /* not implemented */ +} + /* set the log to default function, called during eal init process. */ int eal_log_init(__rte_unused const char *id, __rte_unused int facility) diff --git a/lib/log/version.map b/lib/log/version.map index 6ecc656d1d65..32c555f29e79 100644 --- a/lib/log/version.map +++ b/lib/log/version.map @@ -25,6 +25,7 @@ DPDK_24 { INTERNAL { global: + eal_log_enable_timestamp; eal_log_get_default; eal_log_init; eal_log_level2str; From patchwork Mon Mar 18 18:30:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 138470 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E39D443CE8; Mon, 18 Mar 2024 19:33:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7A7B540DCD; Mon, 18 Mar 2024 19:32:54 +0100 (CET) Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) by mails.dpdk.org (Postfix) with ESMTP id E66F0406B4 for ; Mon, 18 Mar 2024 19:32:48 +0100 (CET) Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3c19aaedfdaso2635673b6e.2 for ; Mon, 18 Mar 2024 11:32:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1710786768; x=1711391568; 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=3FYikwK1xwpaJxKVUawI2osEKSAMSAZcBjVrL37SoHo=; b=YdVGC2BItv4sF20G0l+ULP7m1CTnU+STnP8h1cDjCSrRgXgTocukzcRE2ZRPk+iqwI AnUvw+QQya0lOA4XNTrVPCl29WIf4UkwbkEE8c4ZKg1itUziVduP5Fb91A1C6UOMRkhW KrWL1nVaxOvEq3IbI9Hbb1V58OiZLiH7iJQsCqzxZvwpZ1ZIiwuv8bPGfZoxL2ere4YA elsa22Q4phW14Zf+lCtvaUVR4hNvP053FNrHErx1QEZIgBVFHUjGzS7CtGIJei5zx0fd xhGMi4Pc3gYSBaG52aHztIRsgJwDm3VBdamVT0ZE5F6NPrUs1IeDmbQv/j33rDbPQwbJ EIcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710786768; x=1711391568; 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=3FYikwK1xwpaJxKVUawI2osEKSAMSAZcBjVrL37SoHo=; b=tJ5G3WbbDiEVBlI4NkUW5I/fzuWIOQ4dlxDQHVLjw38+OQpfrJY0jSIItpsCI8YEG7 rUAJJsqtEgzPrlW0HW5jEuvWXze7uohrpVkQFYIeIAi9c98qIbaZK3O5Ro8+JVxElSGt C8v69sxiAa4Xs6WKeBXFhTSan9dMD9vwfTjRNdNt/7P+ayXtYRi/w1QioQWYS+gqpAzh 1X+vwcRwrV/z3CgK6uJE9wr/PMJc4Ro3A8xsIgXUwwsKm9TBVUTLOMwuWfcIp3gngDD6 zcC1PTyNWrJ4UG4f65O+I4B0WEb6aojh18TTpZF1YjpyIQarToBqk/STjknwM1hZh1LR oZnw== X-Gm-Message-State: AOJu0YyKEz0ByOiuWGs3S/4W1st8tdQKXr/9bLznJ4/S0xLZPChAXrHX 8j2GyV8gfmLcA68qCzBYtfT4dedvVUx/yBErUWEsvHtacWRe1a4V7yyZOV9YukmFTSj89SiCQVT R X-Google-Smtp-Source: AGHT+IHtOpaiFIkpZenvb0Qz2zevPnfqU1vGqH9xpYhDG7gQzP2VgUSf+ULAWdwf71NW8YtFBKOWHQ== X-Received: by 2002:a05:6870:8304:b0:220:65ba:ca3a with SMTP id p4-20020a056870830400b0022065baca3amr15519303oae.14.1710786768325; Mon, 18 Mar 2024 11:32:48 -0700 (PDT) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id x6-20020aa784c6000000b006e4e93f4f17sm8186593pfn.117.2024.03.18.11.32.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 11:32:47 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v8 5/5] eal: initialize logging before plugins Date: Mon, 18 Mar 2024 11:30:06 -0700 Message-ID: <20240318183233.142330-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240318183233.142330-1-stephen@networkplumber.org> References: <20200814173441.23086-1-stephen@networkplumber.org> <20240318183233.142330-1-stephen@networkplumber.org> MIME-Version: 1.0 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 Want to make sure that as many log messages as possible get added with the real log stream. Signed-off-by: Stephen Hemminger --- lib/eal/freebsd/eal.c | 16 ++++++++-------- lib/eal/linux/eal.c | 16 ++++++++-------- lib/eal/unix/eal_unix_log.c | 0 3 files changed, 16 insertions(+), 16 deletions(-) create mode 100644 lib/eal/unix/eal_unix_log.c diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index b4f8d68b0a65..e4f00f31fbdd 100644 --- a/lib/eal/freebsd/eal.c +++ b/lib/eal/freebsd/eal.c @@ -592,6 +592,14 @@ rte_eal_init(int argc, char **argv) internal_conf->in_memory = false; } + 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 (eal_plugins_init() < 0) { rte_eal_init_alert("Cannot init plugins"); rte_errno = EINVAL; @@ -718,14 +726,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; - } - /* 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..e24f24b1b0ce 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -973,6 +973,14 @@ rte_eal_init(int argc, char **argv) return -1; } + 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 (eal_plugins_init() < 0) { rte_eal_init_alert("Cannot init plugins"); rte_errno = EINVAL; @@ -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