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 CE4B441C58; Fri, 10 Feb 2023 02:08:48 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A3D6342D39; Fri, 10 Feb 2023 02:08:16 +0100 (CET) Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by mails.dpdk.org (Postfix) with ESMTP id BAC7342D10 for ; Fri, 10 Feb 2023 02:08:11 +0100 (CET) Received: by mail-pj1-f46.google.com with SMTP id o13so3754421pjg.2 for ; Thu, 09 Feb 2023 17:08:11 -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=u5PmRTXPSIIaxxLBFryN+KpAXMIzHlpRzpcU+NO0W+krADo+hmYKmIpUJ1wHkDarTP 0hP2KE4nv0e12m3XKPKTpmUDo8dVCqPAMNaexAGcmAesptX1J/k3hA0C342jaPh3XwCK oQnEQD6FalZyFzwICZCMJ5GOBoArBAr+0x3YaLkO3NWQDVKqrTCTPaoeNDt05UgOjyGD 6ld/qHm8l/GBg4Fv5+EFwzdFuPBJIcy+ApPSLGu+16DuhQ7unneBUXIRuS6FJ4w/M/mG 6zY5a/aZbWffHSvf7KF5AlL3mHx4Lvp+Vkto99Un9UKgEnFL3mf++73jcfC7kH2KxRc2 OtAw== 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=6kIRO7jMf9gB90YStmfSDFWQKqkdQn+sQpGoOhv7ErXiViz+n0Q5nGO/Bq+WJZmqb7 RKM5+QVKq8Vqah1Ylyk+IGm+ECoHdVOeATGKO5lJ5x8fhrlxCEwXeZNLm+u16rJ7F4ds 2rfz+roKur3FeKua2BEi4Y6QF3xrPe+XYyy11/7JVmSjFOugS5YYHS94/LiYp3IDO3T0 toQKXX8JoN8wzUlhovtYdxzGRpEP/QUU+2bqyviJQcoQZniQEHP5532AdqTvr4gPUN2l tT+mDoZV1iLLM3JV31+NgaVz1w6kNoKmNAEhnXUXABtNlGO4hDle3xe0fnWYm3XbBl8D TpAg== X-Gm-Message-State: AO0yUKUoXkiD8+Q6ZNZCTN6m6ZqVhRnAZB1JfuckksOC57gadvgkQNuj 9dFsOPRdzqqMV0j54vQhJBMRPX7OUR2sU1A6c1g= X-Google-Smtp-Source: AK7set8tGN70N9zMRRfSbk60ZelGuKeOU2qe9OZtlFRFMzkD/6wVIV/UOF1jfqs1VSP5CZWl4q9olw== X-Received: by 2002:a17:902:cecf:b0:196:89bc:70fe with SMTP id d15-20020a170902cecf00b0019689bc70femr14123735plg.34.1675991290642; Thu, 09 Feb 2023 17:08:10 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id jd9-20020a170903260900b0019625428cefsm2103023plb.281.2023.02.09.17.08.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 17:08:10 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Olivier Matz , Andrew Rybchenko Subject: [PATCH v3 08/16] mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type Date: Thu, 9 Feb 2023 17:07:16 -0800 Message-Id: <20230210010724.890413-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210010724.890413-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230210010724.890413-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