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 1E70141C50; Fri, 10 Feb 2023 18:16:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BBDDC42D1A; Fri, 10 Feb 2023 18:15:51 +0100 (CET) Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by mails.dpdk.org (Postfix) with ESMTP id 110E242BD9 for ; Fri, 10 Feb 2023 18:15:49 +0100 (CET) Received: by mail-pj1-f41.google.com with SMTP id o13so5844618pjg.2 for ; Fri, 10 Feb 2023 09:15: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=B3lpZCDNiPFh8bGv0DrYY429UmscTuAQ9n7XOCUgWqKMkh/3UzvD681EqfhaC2/jPr 3HUq0k+I1G3E76X0LY5W+s61frUtaFxAtgOOB8PeBYeZHCzTsie08Yj2lrZ6wQH+0P1W izsOAnvtyqCgCUMwkNdIy+S5UpYsYfGwTy9jYX4OeWktwlCPQsSQF+u/VBrH7p6xLH92 2oqJPpFH3uZYh3dizoAunJLvqeSGhfou3Lvh5gqRVSzjcGKoruf3CJbVsQBwf8/9X1CC BzEpgmzf+aBi0pd0lJ6ginPmgZ5A0WRm0PfUfQa7nl04rEj2hRdVcvLPMsafnBnqkp8i T7kg== 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=WWm5nFtbC64Cvtb10nvLku/pplj7dJkZRpZJhHL1WL+9JBBugpbCqfZw/2RdkVg7DX 7tokGB3BoNLYlBtfHmx3TwBsaxViHqkRIUaFyl7LvqN1vqWxG9FNembObCaBP05TUoYT MpyD45lrz2v3PZ7j3qd5YNF+0Tg9IVujwJtJpXZoqq3WgC0DsUEA1KaV7zN/1EWVJDao 3vJls+Wa3dx6gXBR3VveotZLZl7RaYxQmlV7xlcKFoRkzn87dajobw6rq6KgFtF3t+Uj vwmh6JQijor0Lkm04QrABXUxUlt+yP7Tg1r8b4DGHWH+75Wq7XM1SKwGB9ApQOhcscPD BNHg== X-Gm-Message-State: AO0yUKVDj5uTzE+9Nj0JwnwcpNiSVcFEi+9IjiA8Aznqb87ae2DwDhS4 PDB4hPLkFVjYnWhibXry/siGmmQ0sHVJ17ptPg0= X-Google-Smtp-Source: AK7set/lZB5cvq9m1ZXsWUqPQvZg6OiU/w546QmTT38vPpUJ0npoLAHnAuy46456lDYb03XjzOQvfQ== X-Received: by 2002:a17:902:e354:b0:19a:80c9:2cd7 with SMTP id p20-20020a170902e35400b0019a80c92cd7mr54282plc.47.1676049347974; Fri, 10 Feb 2023 09:15:47 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id c1-20020a170902b68100b0019a6e8ceb49sm1955669pls.259.2023.02.10.09.15.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Feb 2023 09:15:47 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , reshma.pattan@intel.com, Remy Horton , Harry van Haaren Subject: [PATCH v4 3/5] latencystats: use dynamic logtype Date: Fri, 10 Feb 2023 09:15:40 -0800 Message-Id: <20230210171542.115434-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210171542.115434-1-stephen@networkplumber.org> References: <20230208044825.1682620-1-stephen@networkplumber.org> <20230210171542.115434-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