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 ABDBF41C34; Wed, 8 Feb 2023 00:06:31 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B757542D6D; Wed, 8 Feb 2023 00:05:22 +0100 (CET) Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by mails.dpdk.org (Postfix) with ESMTP id D144A42D46 for ; Wed, 8 Feb 2023 00:05:18 +0100 (CET) Received: by mail-pj1-f51.google.com with SMTP id o16-20020a17090ad25000b00230759a8c06so369682pjw.2 for ; Tue, 07 Feb 2023 15:05:18 -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=C/T7O65KQL1uw1reJ66M8VpF4ow9LLidnK25FdG2Lis=; b=OvZuTXFTQ4UOxDx8jj0Orh/bImhGZn7A7tgZ1rZIxzDWSkAuNc5NheVp1+2PJlJXtJ FlXe0SWqDcX3t1ij961yE+CxKIpUfJ2QxYFY0XW7j4FV3OsiFTQHGfI3Mu2nDqg5mnjX /eh0UVJywu7hcUJrc8pqVmsaYf/uK7Oo3R/gPyN9Ste/NFTvoutdXJ7VA1ti/+3Ve52M 7jvzpfoNYJ+En49TJeieQvtnc707L4mt7eP35/PAQ91e04Jls1X1GJ5l5G8cxd+1+zTF P7FGEzoWvD1+glNtiPQ2Z+BwCFQ5lUDW8IFFhz3pQ2w/sn7jDUMjN0qGgxTkf9hGP3d7 bHeA== 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=C/T7O65KQL1uw1reJ66M8VpF4ow9LLidnK25FdG2Lis=; b=4F0j/BGp+/Jri0FwGPsyTzCQlnk4vMNKAfQ2whd0tmCQ/IHgD8qj469fAo6rHoeLod VuY354GKoAksMK9/3++Nul0eKpYxOybte1w63M8kwcXl4x3elEOZmo6jBrR5Vv8kHzUv 28qMzECjGUIgkXG46YMqSwmv9IAJRQ8aEtHANHdGEPTy11naAj5FyFD0vEGI2DrLa14Q Z/vkiGxdxkdfXbMBiPqFhK+burbUwRE0pFYHgayJxMT+WwRTaJ6+MWj4stRTJbNiehm8 M6du2CGbF/U5dh4lOllSAcrH1kpjU33QX+dvmrwuJz+SIutUleUuTfwEB8Ybj7L4G7F/ FiBg== X-Gm-Message-State: AO0yUKXRbUHgKfl4XC8w6/aNeuoWAfhvqohQR0ZWW6PLQ7ry8/AQi2xM sfCewH0w6I984AXZXr1YeeIabUvdkdT7hNHpxQk= X-Google-Smtp-Source: AK7set9tU1o6XZk1+0lE+ik8uGln6B/8tzA52RZMwzHQCRSfGDR6moJMfnYpTUhn81OaAr/DKflzMw== X-Received: by 2002:a17:90a:1a52:b0:22c:1b3:b72b with SMTP id 18-20020a17090a1a5200b0022c01b3b72bmr6281046pjl.14.1675811117813; Tue, 07 Feb 2023 15:05:17 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id gq17-20020a17090b105100b0020dc318a43esm71189pjb.25.2023.02.07.15.05.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 15:05:17 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Olivier Matz , Andrew Rybchenko Subject: [RFC v2 12/17] mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type Date: Tue, 7 Feb 2023 15:04:33 -0800 Message-Id: <20230207230438.1617331-13-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207230438.1617331-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230207230438.1617331-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 Convert from RTE_LOGTYPE_MEMPOOL to logtype_mempool. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/mempool/rte_mempool.c | 33 ++++++++++++++++++--------------- lib/mempool/rte_mempool_log.h | 10 ++++++++++ lib/mempool/rte_mempool_ops.c | 12 ++++++------ 5 files changed, 35 insertions(+), 23 deletions(-) create mode 100644 lib/mempool/rte_mempool_log.h diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index 04c9d43351da..90d388192712 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -349,7 +349,6 @@ struct logtype { static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EAL, "lib.eal"}, - {RTE_LOGTYPE_MEMPOOL, "lib.mempool"}, {RTE_LOGTYPE_PMD, "pmd"}, {RTE_LOGTYPE_HASH, "lib.hash"}, {RTE_LOGTYPE_LPM, "lib.lpm"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index a99fe383c89b..f583352ec1ea 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -29,7 +29,7 @@ extern "C" { #define RTE_LOGTYPE_EAL 0 /**< Log related to eal. */ /* was RTE_LOGTYPE_MALLOC */ /* was RTE_LOGTYPE_RING */ -#define RTE_LOGTYPE_MEMPOOL 3 /**< Log related to mempool. */ + /* was RTE_LOGTYPE_MEMPOOL */ /* was RTE_LOGTYPE_TIMER */ #define RTE_LOGTYPE_PMD 5 /**< Log related to poll mode driver. */ #define RTE_LOGTYPE_HASH 6 /**< Log related to hash table. */ diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c index 45b5df6199b0..911a2b4dd850 100644 --- a/lib/mempool/rte_mempool.c +++ b/lib/mempool/rte_mempool.c @@ -30,6 +30,7 @@ #include "rte_mempool.h" #include "rte_mempool_trace.h" +#include "rte_mempool_log.h" TAILQ_HEAD(rte_mempool_list, rte_tailq_entry); @@ -774,7 +775,7 @@ rte_mempool_cache_create(uint32_t size, int socket_id) cache = rte_zmalloc_socket("MEMPOOL_CACHE", sizeof(*cache), RTE_CACHE_LINE_SIZE, socket_id); if (cache == NULL) { - RTE_LOG(ERR, MEMPOOL, "Cannot allocate mempool cache.\n"); + MEMPOOL_LOG(ERR, "Cannot allocate mempool cache."); rte_errno = ENOMEM; return NULL; } @@ -876,7 +877,7 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, /* try to allocate tailq entry */ te = rte_zmalloc("MEMPOOL_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, MEMPOOL, "Cannot allocate tailq entry!\n"); + MEMPOOL_LOG(ERR, "Cannot allocate tailq entry!"); goto exit_unlock; } @@ -1088,25 +1089,25 @@ void rte_mempool_check_cookies(const struct rte_mempool *mp, if (free == 0) { if (cookie != RTE_MEMPOOL_HEADER_COOKIE1) { - RTE_LOG(CRIT, MEMPOOL, - "obj=%p, mempool=%p, cookie=%" PRIx64 "\n", - obj, (const void *) mp, cookie); + MEMPOOL_LOG(CRIT, + "obj=%p, mempool=%p, cookie=%" PRIx64, + obj, (const void *) mp, cookie); rte_panic("MEMPOOL: bad header cookie (put)\n"); } hdr->cookie = RTE_MEMPOOL_HEADER_COOKIE2; } else if (free == 1) { if (cookie != RTE_MEMPOOL_HEADER_COOKIE2) { - RTE_LOG(CRIT, MEMPOOL, - "obj=%p, mempool=%p, cookie=%" PRIx64 "\n", - obj, (const void *) mp, cookie); + MEMPOOL_LOG(CRIT, + "obj=%p, mempool=%p, cookie=%" PRIx64, + obj, (const void *) mp, cookie); rte_panic("MEMPOOL: bad header cookie (get)\n"); } hdr->cookie = RTE_MEMPOOL_HEADER_COOKIE1; } else if (free == 2) { if (cookie != RTE_MEMPOOL_HEADER_COOKIE1 && cookie != RTE_MEMPOOL_HEADER_COOKIE2) { - RTE_LOG(CRIT, MEMPOOL, - "obj=%p, mempool=%p, cookie=%" PRIx64 "\n", + MEMPOOL_LOG(CRIT, + "obj=%p, mempool=%p, cookie=%" PRIx64, obj, (const void *) mp, cookie); rte_panic("MEMPOOL: bad header cookie (audit)\n"); } @@ -1114,9 +1115,9 @@ void rte_mempool_check_cookies(const struct rte_mempool *mp, tlr = rte_mempool_get_trailer(obj); cookie = tlr->cookie; if (cookie != RTE_MEMPOOL_TRAILER_COOKIE) { - RTE_LOG(CRIT, MEMPOOL, - "obj=%p, mempool=%p, cookie=%" PRIx64 "\n", - obj, (const void *) mp, cookie); + MEPOOL_LOG(CRIT, + "obj=%p, mempool=%p, cookie=%" PRIx64, + obj, (const void *) mp, cookie); rte_panic("MEMPOOL: bad trailer cookie\n"); } } @@ -1200,7 +1201,7 @@ mempool_audit_cache(const struct rte_mempool *mp) const struct rte_mempool_cache *cache; cache = &mp->local_cache[lcore_id]; if (cache->len > RTE_DIM(cache->objs)) { - RTE_LOG(CRIT, MEMPOOL, "badness on cache[%u]\n", + MEMPOOL_LOG(CRIT, "badness on cache[%u]", lcore_id); rte_panic("MEMPOOL: invalid cache len\n"); } @@ -1429,7 +1430,7 @@ rte_mempool_event_callback_register(rte_mempool_event_callback *func, cb = calloc(1, sizeof(*cb)); if (cb == NULL) { - RTE_LOG(ERR, MEMPOOL, "Cannot allocate event callback!\n"); + MEMPOOL_LOG(ERR, "Cannot allocate event callback!"); ret = -ENOMEM; goto exit; } @@ -1563,3 +1564,5 @@ RTE_INIT(mempool_init_telemetry) rte_telemetry_register_cmd("/mempool/info", mempool_handle_info, "Returns mempool info. Parameters: pool_name"); } + +RTE_LOG_REGISTER_DEFAULT(mempool_logtype, INFO); diff --git a/lib/mempool/rte_mempool_log.h b/lib/mempool/rte_mempool_log.h new file mode 100644 index 000000000000..3d252f761408 --- /dev/null +++ b/lib/mempool/rte_mempool_log.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2014 Intel Corporation. + * Copyright 2014 6WIND S.A. + */ + +extern int mempool_logtype; + +#define MEMPOOL_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, mempool_logtype, \ + "%s(): " fmt "\n", __func__, ##args) diff --git a/lib/mempool/rte_mempool_ops.c b/lib/mempool/rte_mempool_ops.c index 3b43edc548a0..e04e75b91ba6 100644 --- a/lib/mempool/rte_mempool_ops.c +++ b/lib/mempool/rte_mempool_ops.c @@ -12,6 +12,7 @@ #include #include "rte_mempool_trace.h" +#include "rte_mempool_log.h" /* indirect jump table to support external memory pools. */ struct rte_mempool_ops_table rte_mempool_ops_table = { @@ -31,23 +32,22 @@ rte_mempool_register_ops(const struct rte_mempool_ops *h) if (rte_mempool_ops_table.num_ops >= RTE_MEMPOOL_MAX_OPS_IDX) { rte_spinlock_unlock(&rte_mempool_ops_table.sl); - RTE_LOG(ERR, MEMPOOL, - "Maximum number of mempool ops structs exceeded\n"); + MEMPOOL_LOG(ERR, + "Maximum number of mempool ops structs exceeded"); return -ENOSPC; } if (h->alloc == NULL || h->enqueue == NULL || h->dequeue == NULL || h->get_count == NULL) { rte_spinlock_unlock(&rte_mempool_ops_table.sl); - RTE_LOG(ERR, MEMPOOL, - "Missing callback while registering mempool ops\n"); + MEMPOOL_LOG(ERR, + "Missing callback while registering mempool ops"); return -EINVAL; } if (strlen(h->name) >= sizeof(ops->name) - 1) { rte_spinlock_unlock(&rte_mempool_ops_table.sl); - RTE_LOG(DEBUG, EAL, "%s(): mempool_ops <%s>: name too long\n", - __func__, h->name); + MEMPOOL_LOG(DEBUG, "mempool_ops <%s>: name too long\n", h->name); rte_errno = EEXIST; return -EEXIST; } -- 2.39.1