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 BF90A41C56; Fri, 10 Feb 2023 01:22:46 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B1DDA42D12; Fri, 10 Feb 2023 01:22:33 +0100 (CET) Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by mails.dpdk.org (Postfix) with ESMTP id C0D8542B8C for ; Fri, 10 Feb 2023 01:22:29 +0100 (CET) Received: by mail-pg1-f174.google.com with SMTP id x31so2689877pgl.6 for ; Thu, 09 Feb 2023 16:22:29 -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=1dZnn9oos+M0um08IJoWkSVN1gBPebN8Of5Bq9hL7WlV3ktpHmUSxwFrOqCskh7ZGh QbslLobSbbCqMVr+QGamP05ZPC/I8KjxCB+g2m9VQR7JT1uJ/xIHSR4z2R2hZN93XdXY RiO0bLMaZwta/cBSKHN3lz0Y6JNDhx/SPc4K3/ppTlQkHdAl5KtOriOiTIngzZIlt/z6 xY4Z7tWRayWf4bQ+C0KtudjyKuzyhphxYirnbJl1IEZ4lj0pqu0QlCcInWr+0AD+KYjN BHcOeLbLVqWzcc8UgjJBqU8LaNW/jTeo5qu7Ru3mxOH05W0C5b1354duVKDoMZst/ITW xHIQ== 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=YvzxhBpDY8/dKMjoPvUKxbgtESGg071mxXNpMQ8f8Z0WGbkgbjAU5VUZN/yKvUyrFr W5iWT4vPiATrBcrLvwgSMX3IHyf3B18+sncwRot9xACj1SzWsaXHpe2feK9Mt+6TtrBa 8+5mGSUzxPo8uDDelN3VdST2pi7EFVdkNjmwz69fMEny7Bacm3S7VtZlSNuQ3nU9IDXK 6UMX4nEUsbZqbP+WlHHG3tpcYlfTNelzC/934J5BE4mtq4BNxzKi4RWmvvGjLlKl9iq8 Zb/WeGHqEFNcc9B4Vv81DDv26Kbfp6VqBB/nVJd16NaCInboCkFku0zFyWFoHhhIK/nN FIIA== X-Gm-Message-State: AO0yUKXPlLxNFFDVCYNAhKYt6cM14iXjKLAinUPaFzfSF1HfGyqftECH L83v4I2UpVtmwlCbchRC2NByajAv/5LMPTBERdw= X-Google-Smtp-Source: AK7set8tOeG/AquduPCiAvCJFzxBoAkvRFYFVH6B+Dq0VYPrlFiKHE1eHF45i81qfO/hhR1qnXCnOg== X-Received: by 2002:a05:6a00:b41:b0:5a8:445d:d352 with SMTP id p1-20020a056a000b4100b005a8445dd352mr6317007pfo.11.1675988548654; Thu, 09 Feb 2023 16:22:28 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id g9-20020aa78749000000b005907664a3eesm1986639pfo.125.2023.02.09.16.22.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 16:22:28 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , reshma.pattan@intel.com, Remy Horton , Harry van Haaren Subject: [PATCH v3 3/5] latencystats: use dynamic logtype Date: Thu, 9 Feb 2023 16:22:20 -0800 Message-Id: <20230210002222.812379-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210002222.812379-1-stephen@networkplumber.org> References: <20230208044825.1682620-1-stephen@networkplumber.org> <20230210002222.812379-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