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 D2B6343354; Fri, 17 Nov 2023 14:19:04 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0CD9741149; Fri, 17 Nov 2023 14:18:54 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id C357B41149 for ; Fri, 17 Nov 2023 14:18:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700227132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M1EWUw0sEtSu2Jj3HwkxnwiTgtndFJU/6En0ekJ//XM=; b=Yhx8/LhOPKaRHh+s/nEhOsXy3juOwy5KBm9gTtdzR9Kwxa+yzaJciq9oHuGbyh97XsGVQw IO+QBxvXEj88xTr/9uAuTphfYCG+/kcvodO3+zExU/YdXnVGQDzmakTMCGvs90Azw+jAVe mQOeAEkubhJsJ04ptPDgPERC8NfwBls= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-608-QiKFRZr-NdmfBJ_CI4AMWw-1; Fri, 17 Nov 2023 08:18:51 -0500 X-MC-Unique: QiKFRZr-NdmfBJ_CI4AMWw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DBDAE280D470; Fri, 17 Nov 2023 13:18:49 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.226.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id F3714492BE0; Fri, 17 Nov 2023 13:18:45 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@amd.com, bruce.richardson@intel.com, stephen@networkplumber.org, Nicolas Chautru , Cristian Dumitrescu , Fan Zhang , Ashish Gupta , Akhil Goyal , Chengwen Feng , Kevin Laatz , Jerin Jacob , Erik Gabriel Carrillo , Elena Agostini , Kiran Kumar K , Nithin Dabilpuram , Zhirun Yan , Srikanth Yalavarthi , Jasvinder Singh , Pavan Nikhilesh , Sachin Saxena , Hemant Agrawal , Honnappa Nagarahalli Subject: [RFC 3/3] lib: use per line logging Date: Fri, 17 Nov 2023 14:18:24 +0100 Message-ID: <20231117131824.1977792-4-david.marchand@redhat.com> In-Reply-To: <20231117131824.1977792-1-david.marchand@redhat.com> References: <20231117131824.1977792-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 Use RTE_LOG_LINE in existing macros that append a \n. Signed-off-by: David Marchand --- lib/bbdev/rte_bbdev.c | 3 ++- lib/cfgfile/rte_cfgfile.c | 4 ++-- lib/compressdev/rte_compressdev_internal.h | 5 +++-- lib/cryptodev/rte_cryptodev.h | 16 ++++++++-------- lib/dmadev/rte_dmadev.c | 6 ++++-- lib/eventdev/eventdev_pmd.h | 8 ++++---- lib/eventdev/rte_event_timer_adapter.c | 17 ++++++++++------- lib/gpudev/gpudev.c | 6 ++++-- lib/graph/graph_private.h | 5 +++-- lib/metrics/rte_metrics_telemetry.c | 4 ++-- lib/mldev/rte_mldev.h | 5 +++-- lib/net/rte_net_crc.c | 8 ++++---- lib/node/node_private.h | 6 ++++-- lib/rawdev/rte_rawdev_pmd.h | 4 ++-- lib/rcu/rte_rcu_qsbr.h | 9 ++++----- lib/stack/stack_pvt.h | 4 ++-- 16 files changed, 61 insertions(+), 49 deletions(-) diff --git a/lib/bbdev/rte_bbdev.c b/lib/bbdev/rte_bbdev.c index e09bb97abb..a61aa599aa 100644 --- a/lib/bbdev/rte_bbdev.c +++ b/lib/bbdev/rte_bbdev.c @@ -28,10 +28,11 @@ /* BBDev library logging ID */ RTE_LOG_REGISTER_DEFAULT(bbdev_logtype, NOTICE); +#define RTE_LOGTYPE_BBDEV bbdev_logtype /* Helper macro for logging */ #define rte_bbdev_log(level, fmt, ...) \ - rte_log(RTE_LOG_ ## level, bbdev_logtype, fmt "\n", ##__VA_ARGS__) + RTE_LOG_LINE(level, BBDEV, fmt , ##__VA_ARGS__) #define rte_bbdev_log_debug(fmt, ...) \ rte_bbdev_log(DEBUG, RTE_STR(__LINE__) ":%s() " fmt, __func__, \ diff --git a/lib/cfgfile/rte_cfgfile.c b/lib/cfgfile/rte_cfgfile.c index 2f9cc0722a..6a5e4fd942 100644 --- a/lib/cfgfile/rte_cfgfile.c +++ b/lib/cfgfile/rte_cfgfile.c @@ -29,10 +29,10 @@ struct rte_cfgfile { /* Setting up dynamic logging 8< */ RTE_LOG_REGISTER_DEFAULT(cfgfile_logtype, INFO); +#define RTE_LOGTYPE_CFGFILE cfgfile_logtype #define CFG_LOG(level, fmt, args...) \ - rte_log(RTE_LOG_ ## level, cfgfile_logtype, "%s(): " fmt "\n", \ - __func__, ## args) + RTE_LOG_LINE(level, CFGFILE, "%s(): " fmt, __func__, ## args) /* >8 End of setting up dynamic logging */ /** when we resize a file structure, how many extra entries diff --git a/lib/compressdev/rte_compressdev_internal.h b/lib/compressdev/rte_compressdev_internal.h index b3b193e3ee..34d6d95649 100644 --- a/lib/compressdev/rte_compressdev_internal.h +++ b/lib/compressdev/rte_compressdev_internal.h @@ -21,9 +21,10 @@ extern "C" { /* Logging Macros */ extern int compressdev_logtype; +#define RTE_LOGTYPE_COMPRESSDEV compressdev_logtype + #define COMPRESSDEV_LOG(level, fmt, args...) \ - rte_log(RTE_LOG_ ## level, compressdev_logtype, "%s(): " fmt "\n", \ - __func__, ##args) + RTE_LOG_LINE(level, COMPRESSDEV, "%s(): " fmt, __func__, ##args) /** * Dequeue processed packets from queue pair of a device. diff --git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.h index aaeaf294e6..5131d2d947 100644 --- a/lib/cryptodev/rte_cryptodev.h +++ b/lib/cryptodev/rte_cryptodev.h @@ -31,23 +31,23 @@ extern const char **rte_cyptodev_names; /* Logging Macros */ #define CDEV_LOG_ERR(...) \ - RTE_LOG(ERR, CRYPTODEV, \ - RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \ + RTE_LOG_LINE(ERR, CRYPTODEV, \ + RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,), \ __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,))) #define CDEV_LOG_INFO(...) \ - RTE_LOG(INFO, CRYPTODEV, \ - RTE_FMT(RTE_FMT_HEAD(__VA_ARGS__,) "\n", \ + RTE_LOG_LINE(INFO, CRYPTODEV, \ + RTE_FMT(RTE_FMT_HEAD(__VA_ARGS__,), \ RTE_FMT_TAIL(__VA_ARGS__,))) #define CDEV_LOG_DEBUG(...) \ - RTE_LOG(DEBUG, CRYPTODEV, \ - RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \ + RTE_LOG_LINE(DEBUG, CRYPTODEV, \ + RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,), \ __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,))) #define CDEV_PMD_TRACE(...) \ - RTE_LOG(DEBUG, CRYPTODEV, \ - RTE_FMT("[%s] %s: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \ + RTE_LOG_LINE(DEBUG, CRYPTODEV, \ + RTE_FMT("[%s] %s: " RTE_FMT_HEAD(__VA_ARGS__,), \ dev, __func__, RTE_FMT_TAIL(__VA_ARGS__,))) /** diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c index 009a21849a..c1a166858c 100644 --- a/lib/dmadev/rte_dmadev.c +++ b/lib/dmadev/rte_dmadev.c @@ -32,9 +32,11 @@ static struct { } *dma_devices_shared_data; RTE_LOG_REGISTER_DEFAULT(rte_dma_logtype, INFO); +#define RTE_LOGTYPE_DMA rte_dma_logtype + #define RTE_DMA_LOG(level, ...) \ - rte_log(RTE_LOG_ ## level, rte_dma_logtype, RTE_FMT("dma: " \ - RTE_FMT_HEAD(__VA_ARGS__,) "\n", RTE_FMT_TAIL(__VA_ARGS__,))) + RTE_LOG_LINE(level, DMA, RTE_FMT("dma: " RTE_FMT_HEAD(__VA_ARGS__,), \ + RTE_FMT_TAIL(__VA_ARGS__,))) int rte_dma_dev_max(size_t dev_max) diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h index 2ec5aec0a8..50cf7d9057 100644 --- a/lib/eventdev/eventdev_pmd.h +++ b/lib/eventdev/eventdev_pmd.h @@ -33,14 +33,14 @@ extern "C" { /* Logging Macros */ #define RTE_EDEV_LOG_ERR(...) \ - RTE_LOG(ERR, EVENTDEV, \ - RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \ + RTE_LOG_LINE(ERR, EVENTDEV, \ + RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,), \ __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,))) #ifdef RTE_LIBRTE_EVENTDEV_DEBUG #define RTE_EDEV_LOG_DEBUG(...) \ - RTE_LOG(DEBUG, EVENTDEV, \ - RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \ + RTE_LOG_LINE(DEBUG, EVENTDEV, \ + RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,), \ __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,))) #else #define RTE_EDEV_LOG_DEBUG(...) (void)0 diff --git a/lib/eventdev/rte_event_timer_adapter.c b/lib/eventdev/rte_event_timer_adapter.c index 3f22e85173..6ebb7b257e 100644 --- a/lib/eventdev/rte_event_timer_adapter.c +++ b/lib/eventdev/rte_event_timer_adapter.c @@ -30,27 +30,30 @@ #define DATA_MZ_NAME_FORMAT "rte_event_timer_adapter_data_%d" RTE_LOG_REGISTER_SUFFIX(evtim_logtype, adapter.timer, NOTICE); +#define RTE_LOGTYPE_EVTIM evtim_logtype RTE_LOG_REGISTER_SUFFIX(evtim_buffer_logtype, adapter.timer, NOTICE); +#define RTE_LOGTYPE_EVTIM_BUF evtim_buffer_logtype RTE_LOG_REGISTER_SUFFIX(evtim_svc_logtype, adapter.timer.svc, NOTICE); +#define RTE_LOGTYPE_EVTIM_SVC evtim_svc_logtype static struct rte_event_timer_adapter *adapters; static const struct event_timer_adapter_ops swtim_ops; #define EVTIM_LOG(level, logtype, ...) \ - rte_log(RTE_LOG_ ## level, logtype, \ - RTE_FMT("EVTIMER: %s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) \ - "\n", __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,))) + RTE_LOG_LINE(level, logtype, \ + RTE_FMT("EVTIMER: %s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,), \ + __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,))) -#define EVTIM_LOG_ERR(...) EVTIM_LOG(ERR, evtim_logtype, __VA_ARGS__) +#define EVTIM_LOG_ERR(...) EVTIM_LOG(ERR, EVTIM, __VA_ARGS__) #ifdef RTE_LIBRTE_EVENTDEV_DEBUG #define EVTIM_LOG_DBG(...) \ - EVTIM_LOG(DEBUG, evtim_logtype, __VA_ARGS__) + EVTIM_LOG(DEBUG, EVTIM, __VA_ARGS__) #define EVTIM_BUF_LOG_DBG(...) \ - EVTIM_LOG(DEBUG, evtim_buffer_logtype, __VA_ARGS__) + EVTIM_LOG(DEBUG, EVTIM_BUF, __VA_ARGS__) #define EVTIM_SVC_LOG_DBG(...) \ - EVTIM_LOG(DEBUG, evtim_svc_logtype, __VA_ARGS__) + EVTIM_LOG(DEBUG, EVTIM_SVC, __VA_ARGS__) #else #define EVTIM_LOG_DBG(...) (void)0 #define EVTIM_BUF_LOG_DBG(...) (void)0 diff --git a/lib/gpudev/gpudev.c b/lib/gpudev/gpudev.c index 6845d18b4d..79118c3e94 100644 --- a/lib/gpudev/gpudev.c +++ b/lib/gpudev/gpudev.c @@ -17,9 +17,11 @@ /* Logging */ RTE_LOG_REGISTER_DEFAULT(gpu_logtype, NOTICE); +#define RTE_LOGTYPE_GPUDEV gpu_logtype + #define GPU_LOG(level, ...) \ - rte_log(RTE_LOG_ ## level, gpu_logtype, RTE_FMT("gpu: " \ - RTE_FMT_HEAD(__VA_ARGS__, ) "\n", RTE_FMT_TAIL(__VA_ARGS__, ))) + RTE_LOG_LINE(level, GPUDEV, RTE_FMT("gpu: " RTE_FMT_HEAD(__VA_ARGS__, ), \ + RTE_FMT_TAIL(__VA_ARGS__, ))) /* Set any driver error as EPERM */ #define GPU_DRV_RET(function) \ diff --git a/lib/graph/graph_private.h b/lib/graph/graph_private.h index d0ef13b205..672a034287 100644 --- a/lib/graph/graph_private.h +++ b/lib/graph/graph_private.h @@ -18,10 +18,11 @@ #include "rte_graph_worker.h" extern int rte_graph_logtype; +#define RTE_LOGTYPE_GRAPH rte_graph_logtype #define GRAPH_LOG(level, ...) \ - rte_log(RTE_LOG_##level, rte_graph_logtype, \ - RTE_FMT("GRAPH: %s():%u " RTE_FMT_HEAD(__VA_ARGS__, ) "\n", \ + RTE_LOG_LINE(level, GRAPH, \ + RTE_FMT("GRAPH: %s():%u " RTE_FMT_HEAD(__VA_ARGS__, ), \ __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__, ))) #define graph_err(...) GRAPH_LOG(ERR, __VA_ARGS__) diff --git a/lib/metrics/rte_metrics_telemetry.c b/lib/metrics/rte_metrics_telemetry.c index 1d133e1f8c..169590fdb7 100644 --- a/lib/metrics/rte_metrics_telemetry.c +++ b/lib/metrics/rte_metrics_telemetry.c @@ -16,11 +16,11 @@ struct telemetry_metrics_data tel_met_data; int metrics_log_level; +#define RTE_LOGTYPE_METRICS metrics_log_level /* Logging Macros */ #define METRICS_LOG(level, fmt, args...) \ - rte_log(RTE_LOG_ ##level, metrics_log_level, "%s(): "fmt "\n", \ - __func__, ##args) + RTE_LOG_LINE(level, METRICS, "%s(): "fmt, __func__, ##args) #define METRICS_LOG_ERR(fmt, args...) \ METRICS_LOG(ERR, fmt, ## args) diff --git a/lib/mldev/rte_mldev.h b/lib/mldev/rte_mldev.h index 63b2670bb0..5cf6f0566f 100644 --- a/lib/mldev/rte_mldev.h +++ b/lib/mldev/rte_mldev.h @@ -144,9 +144,10 @@ extern "C" { /* Logging Macro */ extern int rte_ml_dev_logtype; +#define RTE_LOGTYPE_MLDEV rte_ml_dev_logtype -#define RTE_MLDEV_LOG(level, fmt, args...) \ - rte_log(RTE_LOG_##level, rte_ml_dev_logtype, "%s(): " fmt "\n", __func__, ##args) +#define RTE_MLDEV_LOG(level, fmt, args...) \ + RTE_LOG_LINE(level, MLDEV, "%s(): " fmt, __func__, ##args) #define RTE_ML_STR_MAX 128 /**< Maximum length of name string */ diff --git a/lib/net/rte_net_crc.c b/lib/net/rte_net_crc.c index 900d6de7f4..b401ea3dd8 100644 --- a/lib/net/rte_net_crc.c +++ b/lib/net/rte_net_crc.c @@ -70,11 +70,11 @@ static const rte_net_crc_handler handlers_neon[] = { static uint16_t max_simd_bitwidth; -#define NET_LOG(level, fmt, args...) \ - rte_log(RTE_LOG_ ## level, libnet_logtype, "%s(): " fmt "\n", \ - __func__, ## args) - RTE_LOG_REGISTER_DEFAULT(libnet_logtype, INFO); +#define RTE_LOGTYPE_NET libnet_logtype + +#define NET_LOG(level, fmt, args...) \ + RTE_LOG_LINE(level, NET, "%s(): " fmt, __func__, ## args) /* Scalar handling */ diff --git a/lib/node/node_private.h b/lib/node/node_private.h index 26135aaa5b..5702146db4 100644 --- a/lib/node/node_private.h +++ b/lib/node/node_private.h @@ -11,9 +11,11 @@ #include extern int rte_node_logtype; +#define RTE_LOGTYPE_NODE rte_node_logtype + #define NODE_LOG(level, node_name, ...) \ - rte_log(RTE_LOG_##level, rte_node_logtype, \ - RTE_FMT("NODE %s: %s():%u " RTE_FMT_HEAD(__VA_ARGS__, ) "\n", \ + RTE_LOG_LINE(level, NODE, \ + RTE_FMT("NODE %s: %s():%u " RTE_FMT_HEAD(__VA_ARGS__, ), \ node_name, __func__, __LINE__, \ RTE_FMT_TAIL(__VA_ARGS__, ))) diff --git a/lib/rawdev/rte_rawdev_pmd.h b/lib/rawdev/rte_rawdev_pmd.h index 7b9ef1d09f..7173282c66 100644 --- a/lib/rawdev/rte_rawdev_pmd.h +++ b/lib/rawdev/rte_rawdev_pmd.h @@ -27,11 +27,11 @@ extern "C" { #include "rte_rawdev.h" extern int librawdev_logtype; +#define RTE_LOGTYPE_RAWDEV librawdev_logtype /* Logging Macros */ #define RTE_RDEV_LOG(level, fmt, args...) \ - rte_log(RTE_LOG_ ## level, librawdev_logtype, "%s(): " fmt "\n", \ - __func__, ##args) + RTE_LOG_LINE(level, RAWDEV, "%s(): " fmt, __func__, ##args) #define RTE_RDEV_ERR(fmt, args...) \ RTE_RDEV_LOG(ERR, fmt, ## args) diff --git a/lib/rcu/rte_rcu_qsbr.h b/lib/rcu/rte_rcu_qsbr.h index 6b908e7ee0..23c9f89805 100644 --- a/lib/rcu/rte_rcu_qsbr.h +++ b/lib/rcu/rte_rcu_qsbr.h @@ -36,20 +36,19 @@ extern "C" { #include extern int rte_rcu_log_type; +#define RTE_LOGTYPE_RCU rte_rcu_log_type #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG #define __RTE_RCU_DP_LOG(level, fmt, args...) \ - rte_log(RTE_LOG_ ## level, rte_rcu_log_type, \ - "%s(): " fmt "\n", __func__, ## args) + RTE_LOG_LINE(level, RCU, "%s(): " fmt, __func__, ## args) #else #define __RTE_RCU_DP_LOG(level, fmt, args...) #endif #if defined(RTE_LIBRTE_RCU_DEBUG) -#define __RTE_RCU_IS_LOCK_CNT_ZERO(v, thread_id, level, fmt, args...) do {\ +#define __RTE_RCU_IS_LOCK_CNT_ZERO(v, thread_id, level, fmt, args...) do { \ if (v->qsbr_cnt[thread_id].lock_cnt) \ - rte_log(RTE_LOG_ ## level, rte_rcu_log_type, \ - "%s(): " fmt "\n", __func__, ## args); \ + RTE_LOG_LINE(level, RCU, "%s(): " fmt, __func__, ## args); \ } while (0) #else #define __RTE_RCU_IS_LOCK_CNT_ZERO(v, thread_id, level, fmt, args...) diff --git a/lib/stack/stack_pvt.h b/lib/stack/stack_pvt.h index c7eab4027d..2dce42a9da 100644 --- a/lib/stack/stack_pvt.h +++ b/lib/stack/stack_pvt.h @@ -8,10 +8,10 @@ #include extern int stack_logtype; +#define RTE_LOGTYPE_STACK stack_logtype #define STACK_LOG(level, fmt, args...) \ - rte_log(RTE_LOG_ ##level, stack_logtype, "%s(): "fmt "\n", \ - __func__, ##args) + RTE_LOG_LINE(level, STACK, "%s(): "fmt, __func__, ##args) #define STACK_LOG_ERR(fmt, args...) \ STACK_LOG(ERR, fmt, ## args) -- 2.41.0