DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	reshma.pattan@intel.com, Remy Horton <remy.horton@intel.com>,
	Harry van Haaren <harry.van.haaren@intel.com>
Subject: [PATCH 3/5] latencystats: use dynamic logtype
Date: Tue,  7 Feb 2023 20:48:23 -0800	[thread overview]
Message-ID: <20230208044825.1682620-4-stephen@networkplumber.org> (raw)
In-Reply-To: <20230208044825.1682620-1-stephen@networkplumber.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 <stephen@networkplumber.org>
---
 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(&timestamp_dynfield_offset,
 			&timestamp_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


  parent reply	other threads:[~2023-02-08  4:48 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-08  4:48 [PATCH 0/5] Fix use of RTE_LOGTYPE_USER1 in libraries Stephen Hemminger
2023-02-08  4:48 ` [PATCH 1/5] ip_frag: use a dynamic logtype Stephen Hemminger
2023-02-08 23:52   ` Konstantin Ananyev
2023-02-08  4:48 ` [PATCH 2/5] reorder: " Stephen Hemminger
2023-02-08  4:48 ` Stephen Hemminger [this message]
2023-02-08  4:48 ` [PATCH 4/5] vhost: use logtype instead of RTE_LOGTYPE_USER1 Stephen Hemminger
2023-02-09  7:19   ` Xia, Chenbo
2023-02-08  4:48 ` [PATCH 5/5] ipsec: fix usage " Stephen Hemminger
2023-02-10  0:22 ` [PATCH v3 0/5] Replace use of RTE_LOGTYPE_USER1 in library Stephen Hemminger
2023-02-10  0:22   ` [PATCH v3 1/5] ip_frag: use a dynamic logtype Stephen Hemminger
2023-02-10  0:22   ` [PATCH v3 2/5] reorder: " Stephen Hemminger
2023-02-10  0:22   ` [PATCH v3 3/5] latencystats: use " Stephen Hemminger
2023-02-10  0:22   ` [PATCH v3 4/5] vhost: use logtype instead of RTE_LOGTYPE_USER1 Stephen Hemminger
2023-02-10  9:58     ` Maxime Coquelin
2023-02-10  0:22   ` [PATCH v3 5/5] ipsec: fix usage " Stephen Hemminger
2023-02-10 17:15 ` [PATCH v4 0/5] Replace use of RTE_LOGTYPE_USER1 in library Stephen Hemminger
2023-02-10 17:15   ` [PATCH v4 1/5] ip_frag: use a dynamic logtype Stephen Hemminger
2023-02-10 17:15   ` [PATCH v4 2/5] reorder: " Stephen Hemminger
2023-02-10 17:15   ` [PATCH v4 3/5] latencystats: use " Stephen Hemminger
2023-02-10 17:15   ` [PATCH v4 4/5] vhost: use logtype instead of RTE_LOGTYPE_USER1 Stephen Hemminger
2023-02-10 17:15   ` [PATCH v4 5/5] ipsec: fix usage " Stephen Hemminger
2023-02-12 16:14 ` [PATCH 0/5] Replace us of RTE_LOGTYPE_USER1 in libraries Stephen Hemminger
2023-02-12 16:14   ` [PATCH 1/5] ip_frag: use a dynamic logtype Stephen Hemminger
2023-02-12 16:14   ` [PATCH 2/5] reorder: " Stephen Hemminger
2023-02-12 16:14   ` [PATCH 3/5] latencystats: use " Stephen Hemminger
2023-02-12 16:14   ` [PATCH 4/5] vhost: use logtype instead of RTE_LOGTYPE_USER1 Stephen Hemminger
2023-02-12 16:14   ` [PATCH 5/5] ipsec: fix usage " Stephen Hemminger
2023-02-20 18:49 ` [PATCH v6 0/5] Replace use of RTE_LOGTYPE_USER1 in libraries Stephen Hemminger
2023-02-20 18:49   ` [PATCH v6 1/5] ip_frag: use a dynamic logtype Stephen Hemminger
2023-02-21 10:41     ` David Marchand
2023-02-20 18:49   ` [PATCH v6 2/5] reorder: " Stephen Hemminger
2023-02-20 18:49   ` [PATCH v6 3/5] latencystats: use " Stephen Hemminger
2023-02-20 18:50   ` [PATCH v6 4/5] vhost: use logtype instead of RTE_LOGTYPE_USER1 Stephen Hemminger
2023-02-21 10:39     ` David Marchand
2023-02-20 18:50   ` [PATCH v6 5/5] ipsec: fix usage " Stephen Hemminger
2023-02-21 10:42   ` [PATCH v6 0/5] Replace use of RTE_LOGTYPE_USER1 in libraries David Marchand
2023-02-21 18:46     ` Stephen Hemminger
2023-08-14 16:31 ` [PATCH v8 0/6] Convert " Stephen Hemminger
2023-08-14 16:31   ` [PATCH v8 1/6] ip_frag: use a dynamic logtype Stephen Hemminger
2023-12-01  8:10     ` David Marchand
2023-12-01 12:16       ` Konstantin Ananyev
2023-12-01 13:11         ` David Marchand
2023-08-14 16:31   ` [PATCH v8 2/6] reorder: " Stephen Hemminger
2023-08-16  8:29     ` [EXT] " Volodymyr Fialko
2023-08-14 16:31   ` [PATCH v8 3/6] latencystats: use " Stephen Hemminger
2023-08-14 16:31   ` [PATCH v8 4/6] vhost: use logtype instead of RTE_LOGTYPE_USER1 Stephen Hemminger
2023-08-14 16:31   ` [PATCH v8 5/6] ipsec: fix usage " Stephen Hemminger
2023-08-14 16:31   ` [PATCH v8 6/6] power: use a dynamic logtype for guest channel Stephen Hemminger
2023-08-14 17:41   ` [PATCH v8 0/6] Convert use of RTE_LOGTYPE_USER1 in libraries Morten Brørup
2023-12-04 12:25   ` David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230208044825.1682620-4-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=harry.van.haaren@intel.com \
    --cc=remy.horton@intel.com \
    --cc=reshma.pattan@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).