From patchwork Thu Mar 9 04:57:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 124882 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2234141E2F; Thu, 9 Mar 2023 05:57:59 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F3D6241151; Thu, 9 Mar 2023 05:57:58 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id B061540A7E for ; Thu, 9 Mar 2023 05:57:57 +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 ADCB9C14; Wed, 8 Mar 2023 20:58:40 -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 1B70A3F67D; 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 1/4] mempool: clarify mempool cache flush API behavior Date: Wed, 8 Mar 2023 22:57:35 -0600 Message-Id: <20230309045738.1261000-2-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 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 Clarify that mempool cache flush API works with default mempool cache. It is applications responsibility to validate that the cache belongs to the specified mempool. Signed-off-by: Honnappa Nagarahalli Reviewed-by: Kamalakshitha Aligeri Reviewed-by: Ruifeng Wang Acked-by: Morten Brørup --- lib/mempool/rte_mempool.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h index 9f530db24b..009bd10215 100644 --- a/lib/mempool/rte_mempool.h +++ b/lib/mempool/rte_mempool.h @@ -1326,10 +1326,14 @@ rte_mempool_default_cache(struct rte_mempool *mp, unsigned lcore_id) } /** - * Flush a user-owned mempool cache to the specified mempool. + * Flush a mempool cache to the specified mempool. + * + * It is application's responsibility to validate that the mempool cache + * belongs to the specified mempool. * * @param cache - * A pointer to the mempool cache. + * A pointer to the mempool cache. If NULL, default mempool cache + * is used if configured. * @param mp * A pointer to the mempool. */ From patchwork Thu Mar 9 04:57:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 124883 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8B9C641E2F; Thu, 9 Mar 2023 05:58:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9379042B71; Thu, 9 Mar 2023 05:58:00 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id D6B8341611 for ; Thu, 9 Mar 2023 05:57:57 +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 D10DBFEC; Wed, 8 Mar 2023 20:58:40 -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 3ECD93F67D; 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 2/4] mempool: clarify comments for mempool cache implementation Date: Wed, 8 Mar 2023 22:57:36 -0600 Message-Id: <20230309045738.1261000-3-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 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 Clarify that the mempool cache create and free API implementations work on user owned mempool caches. Signed-off-by: Honnappa Nagarahalli Reviewed-by: Kamalakshitha Aligeri Reviewed-by: Ruifeng Wang --- lib/mempool/rte_mempool.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c index cf5dea2304..a46d855dbf 100644 --- a/lib/mempool/rte_mempool.c +++ b/lib/mempool/rte_mempool.c @@ -757,9 +757,9 @@ mempool_cache_init(struct rte_mempool_cache *cache, uint32_t size) } /* - * Create and initialize a cache for objects that are retrieved from and - * returned to an underlying mempool. This structure is identical to the - * local_cache[lcore_id] pointed to by the mempool structure. + * Create and initialize a user owned cache for objects that are retrieved + * from and returned to an underlying mempool. This structure is identical + * to the local_cache[lcore_id] pointed to by the mempool structure. */ struct rte_mempool_cache * rte_mempool_cache_create(uint32_t size, int socket_id) @@ -786,9 +786,9 @@ rte_mempool_cache_create(uint32_t size, int socket_id) } /* - * Free a cache. It's the responsibility of the user to make sure that any - * remaining objects in the cache are flushed to the corresponding - * mempool. + * Free a user owned cache. It's the responsibility of the user to make + * sure that any remaining objects in the cache are flushed to the + * corresponding mempool. */ void rte_mempool_cache_free(struct rte_mempool_cache *cache) From patchwork Thu Mar 9 04:57:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 124884 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4F03441E2F; Thu, 9 Mar 2023 05:58:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C9ED942BC9; Thu, 9 Mar 2023 05:58:01 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id 09EB840A7E 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 0025B1042; 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 61D493F67D; 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 3/4] eal: add API to check if lcore id is valid Date: Wed, 8 Mar 2023 22:57:37 -0600 Message-Id: <20230309045738.1261000-4-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 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 Simple API to check if the lcore ID does not exceed the maximum number of lcores configured. Signed-off-by: Honnappa Nagarahalli Reviewed-by: Ruifeng Wang --- lib/eal/include/rte_lcore.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/eal/include/rte_lcore.h b/lib/eal/include/rte_lcore.h index 6a355e9986..cf99919a02 100644 --- a/lib/eal/include/rte_lcore.h +++ b/lib/eal/include/rte_lcore.h @@ -38,6 +38,20 @@ enum rte_lcore_role_t { ROLE_NON_EAL, }; +/** + * Check if the lcore ID is valid + * + * @param lcore_id + * The identifier of the lcore. + * + * @return + * True if the given lcore ID is between 0 and RTE_MAX_LCORE-1. + */ +static inline int rte_lcore_id_is_valid(unsigned int lcore_id) +{ + return (lcore_id < RTE_MAX_LCORE); +} + /** * Get a lcore's role. * From patchwork Thu Mar 9 04:57:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 124885 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org 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 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,