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 E29BF41C54; Thu, 9 Feb 2023 18:12:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4C06042C54; Thu, 9 Feb 2023 18:11:51 +0100 (CET) Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by mails.dpdk.org (Postfix) with ESMTP id BE52D42B8C for ; Thu, 9 Feb 2023 18:11:48 +0100 (CET) Received: by mail-pj1-f47.google.com with SMTP id gj9-20020a17090b108900b0023114156d36so6507199pjb.4 for ; Thu, 09 Feb 2023 09:11:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; 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=gvTgzcLHWczeKJnkpsC+rJhEoBxEk1W8Qv+jCAnORCk=; b=iZVmB+WVRQBtz+ry2gD88lsXZQ7WR6AdgSq38YlRz3F8cLdycnuJDC993vu6loJzt8 fqCMf0d24343wzArEyM1cPUNKHnjf2oYWKHMGzA6IhRzIwQpd0daelFdvktDgVRWGP3B yo4R/BVzwaZEWpNV8/iRzTEx934FKJf3GFBz7QkB7oBQBMTFlomucUQB8PKP9QKPdC1t GL8EY5hl8cFBoeXt6QM+WrpitnVkcsehF6muuRfQJQ1OW5rQw3sRgrmSr5yz4yVTk4sT sJifQyo/4cnSksVW1ErOZYe0SFCML/jhyAPloeCzgdlf9WMgh32Wa1sbTTeERPtLEqFF zhdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=gvTgzcLHWczeKJnkpsC+rJhEoBxEk1W8Qv+jCAnORCk=; b=BD+fx01A6QRKzg0vgLJNeQfUGERZSxlhKueoEBb3d7okbxJPsjc0kA2WThnI6KN96N CjhCuxacqpIfdlWSPni4FW9Go5Oh3sow+KvKWDD70C6BLvHaQZPSMfNSihdFAmKB7Qj3 5MZ5qsHh4/Mn8qWYv8QZ4V/+wyEmxEx84lX9ZKGWyWbO72jYqFZOeGTvo5Zl7WZFcbur Tp75VFeUsizlfw9t+BtkVU4II8BUmoALqURIhEfcoLwLw+DOqIKT8RXAy70ATUg7pSZo DXeQ+V9+WXZZGOQT8hJpOUfS8bQWEkoJPXf0W0vn2TPR9MSgKwRim6OXEZPltryrL20t TNqQ== X-Gm-Message-State: AO0yUKXpB9zNho8OPfPPDWyCJuCxY2wQhDX6xvHRLhCQcbyokIOGi9h1 5IINqA9+v+DsIJ5VjFxSYZXqZwLyHoWCz0QOaFk= X-Google-Smtp-Source: AK7set+gOcBIq9aOqyaqVn0yL1nZjiLesHFjzV3oBTJ+E52ydImQfQ69axD6sqAk7kXLRfBbBYhNfA== X-Received: by 2002:a17:902:c611:b0:198:f245:63b3 with SMTP id r17-20020a170902c61100b00198f24563b3mr8921179plr.36.1675962707649; Thu, 09 Feb 2023 09:11:47 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id l5-20020a170902d34500b00188fc6766d6sm1732649plk.219.2023.02.09.09.11.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 09:11:47 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , reshma.pattan@intel.com, Remy Horton , Harry van Haaren Subject: [PATCH v2 3/5] latencystats: use dynamic logtype Date: Thu, 9 Feb 2023 09:11:40 -0800 Message-Id: <20230209171142.94938-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209171142.94938-1-stephen@networkplumber.org> References: <[200~https://inbox.dpdk.org/dev/20230208044825.1682620-1-stephen@networkplumber.org> <20230209171142.94938-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 Libraries should not reuse RTE_LOGTYPE_USER1 for their logging. Instead they should register their own type. Fixes: 5cd3cac9ed22 ("latency: added new library for latency stats") Cc: reshma.pattan@intel.com Signed-off-by: Stephen Hemminger --- lib/latencystats/rte_latencystats.c | 55 +++++++++++++++-------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c index 8985a377db4e..3a4c47e2b34a 100644 --- a/lib/latencystats/rte_latencystats.c +++ b/lib/latencystats/rte_latencystats.c @@ -26,7 +26,10 @@ latencystat_cycles_per_ns(void) } /* Macros for printing using RTE_LOG */ -#define RTE_LOGTYPE_LATENCY_STATS RTE_LOGTYPE_USER1 +RTE_LOG_REGISTER_DEFAULT(latencystat_logtype, INFO); +#define LATENCYSTATS_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, latencystat_logtype, \ + "%s(): " fmt "\n", __func__, ## args) static uint64_t timestamp_dynflag; static int timestamp_dynfield_offset = -1; @@ -95,7 +98,7 @@ rte_latencystats_update(void) latency_stats_index, values, NUM_LATENCY_STATS); if (ret < 0) - RTE_LOG(INFO, LATENCY_STATS, "Failed to push the stats\n"); + LATENCYSTATS_LOG(INFO, "Failed to push the stats"); return ret; } @@ -227,8 +230,7 @@ rte_latencystats_init(uint64_t app_samp_intvl, mz = rte_memzone_reserve(MZ_RTE_LATENCY_STATS, sizeof(*glob_stats), rte_socket_id(), flags); if (mz == NULL) { - RTE_LOG(ERR, LATENCY_STATS, "Cannot reserve memory: %s:%d\n", - __func__, __LINE__); + LATENCYSTATS_LOG(ERR, "Cannot reserve memory"); return -ENOMEM; } @@ -243,8 +245,7 @@ rte_latencystats_init(uint64_t app_samp_intvl, latency_stats_index = rte_metrics_reg_names(ptr_strings, NUM_LATENCY_STATS); if (latency_stats_index < 0) { - RTE_LOG(DEBUG, LATENCY_STATS, - "Failed to register latency stats names\n"); + LATENCYSTATS_LOG(ERR, "Failed to register latency stats names"); return -1; } @@ -252,8 +253,8 @@ rte_latencystats_init(uint64_t app_samp_intvl, ret = rte_mbuf_dyn_rx_timestamp_register(×tamp_dynfield_offset, ×tamp_dynflag); if (ret != 0) { - RTE_LOG(ERR, LATENCY_STATS, - "Cannot register mbuf field/flag for timestamp\n"); + LATENCYSTATS_LOG(ERR, + "Cannot register mbuf field/flag for timestamp"); return -rte_errno; } @@ -263,9 +264,9 @@ rte_latencystats_init(uint64_t app_samp_intvl, ret = rte_eth_dev_info_get(pid, &dev_info); if (ret != 0) { - RTE_LOG(INFO, LATENCY_STATS, - "Error during getting device (port %u) info: %s\n", - pid, strerror(-ret)); + LATENCYSTATS_LOG(INFO, + "Error during getting device (port %u) info: %s", + pid, strerror(-ret)); continue; } @@ -275,18 +276,18 @@ rte_latencystats_init(uint64_t app_samp_intvl, cbs->cb = rte_eth_add_first_rx_callback(pid, qid, add_time_stamps, user_cb); if (!cbs->cb) - RTE_LOG(INFO, LATENCY_STATS, "Failed to " - "register Rx callback for pid=%d, " - "qid=%d\n", pid, qid); + LATENCYSTATS_LOG(INFO, + "Failed to register Rx callback for pid=%d, qid=%d", + pid, qid); } for (qid = 0; qid < dev_info.nb_tx_queues; qid++) { cbs = &tx_cbs[pid][qid]; cbs->cb = rte_eth_add_tx_callback(pid, qid, calc_latency, user_cb); if (!cbs->cb) - RTE_LOG(INFO, LATENCY_STATS, "Failed to " - "register Tx callback for pid=%d, " - "qid=%d\n", pid, qid); + LATENCYSTATS_LOG(INFO, + "Failed to register Tx callback for pid=%d, qid=%d", + pid, qid); } } return 0; @@ -307,8 +308,8 @@ rte_latencystats_uninit(void) ret = rte_eth_dev_info_get(pid, &dev_info); if (ret != 0) { - RTE_LOG(INFO, LATENCY_STATS, - "Error during getting device (port %u) info: %s\n", + LATENCYSTATS_LOG(INFO, + "Error during getting device (port %u) info: %s", pid, strerror(-ret)); continue; @@ -318,17 +319,17 @@ rte_latencystats_uninit(void) cbs = &rx_cbs[pid][qid]; ret = rte_eth_remove_rx_callback(pid, qid, cbs->cb); if (ret) - RTE_LOG(INFO, LATENCY_STATS, "failed to " - "remove Rx callback for pid=%d, " - "qid=%d\n", pid, qid); + LATENCYSTATS_LOG(INFO, + "failed to remove Rx callback for pid=%d, qid=%d", + pid, qid); } for (qid = 0; qid < dev_info.nb_tx_queues; qid++) { cbs = &tx_cbs[pid][qid]; ret = rte_eth_remove_tx_callback(pid, qid, cbs->cb); if (ret) - RTE_LOG(INFO, LATENCY_STATS, "failed to " - "remove Tx callback for pid=%d, " - "qid=%d\n", pid, qid); + LATENCYSTATS_LOG(INFO, + "failed to remove Tx callback for pid=%d, qid=%d", + pid, qid); } } @@ -365,8 +366,8 @@ rte_latencystats_get(struct rte_metric_value *values, uint16_t size) const struct rte_memzone *mz; mz = rte_memzone_lookup(MZ_RTE_LATENCY_STATS); if (mz == NULL) { - RTE_LOG(ERR, LATENCY_STATS, - "Latency stats memzone not found\n"); + LATENCYSTATS_LOG(ERR, + "Latency stats memzone not found"); return -ENOMEM; } glob_stats = mz->addr; -- 2.39.1