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 86B7141E2F; Thu, 9 Mar 2023 05:58:14 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D7C4C42C76; Thu, 9 Mar 2023 05:58:02 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id 20D844161A for ; Thu, 9 Mar 2023 05:57:58 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 231FF1756; Wed, 8 Mar 2023 20:58:41 -0800 (PST) Received: from 2p2660v4-1.austin.arm.com (2p2660v4-1.austin.arm.com [10.118.14.10]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 850D93F67D; Wed, 8 Mar 2023 20:57:57 -0800 (PST) From: Honnappa Nagarahalli To: mb@smartsharesystems.com, olivier.matz@6wind.com, konstantin.v.ananyev@yandex.ru Cc: dev@dpdk.org, honnappa.nagarahalli@arm.com, ruifeng.wang@arm.com, kamalakshitha.aligeri@arm.com, wathsala.vithanage@arm.com, nd@arm.com Subject: [PATCH 4/4] mempool: use lcore API to check if lcore ID is valid Date: Wed, 8 Mar 2023 22:57:38 -0600 Message-Id: <20230309045738.1261000-5-honnappa.nagarahalli@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230309045738.1261000-1-honnappa.nagarahalli@arm.com> References: <20230309045738.1261000-1-honnappa.nagarahalli@arm.com> 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 Use lcore API to check if the lcore ID is valid. The runtime check does not add much value. Hence use assert to validate the lcore ID. Signed-off-by: Honnappa Nagarahalli Reviewed-by: Wathsala Vithanage Reviewed-by: Ruifeng Wang --- lib/mempool/rte_mempool.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h index 009bd10215..00c5aa961b 100644 --- a/lib/mempool/rte_mempool.h +++ b/lib/mempool/rte_mempool.h @@ -1314,10 +1314,9 @@ rte_mempool_cache_free(struct rte_mempool_cache *cache); static __rte_always_inline struct rte_mempool_cache * rte_mempool_default_cache(struct rte_mempool *mp, unsigned lcore_id) { - if (mp->cache_size == 0) - return NULL; + RTE_ASSERT(rte_lcore_id_is_valid(lcore_id)); - if (lcore_id >= RTE_MAX_LCORE) + if (mp->cache_size == 0) return NULL; rte_mempool_trace_default_cache(mp, lcore_id, -- 2.25.1