From patchwork Sun Oct 9 11:11:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 117732 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 C9B32A0542; Sun, 9 Oct 2022 13:12:01 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A61C0400D5; Sun, 9 Oct 2022 13:12:00 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 48F6E40042 for ; Sun, 9 Oct 2022 13:11:59 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 115) id 9E8067F; Sun, 9 Oct 2022 14:11:58 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mail1.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD autolearn=no autolearn_force=no version=3.4.6 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id F065766; Sun, 9 Oct 2022 14:11:57 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru F065766 Authentication-Results: shelob.oktetlabs.ru/F065766; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Olivier Matz Cc: dev@dpdk.org, =?utf-8?q?Morten_Br=C3=B8rup?= Subject: [PATCH 1/2] mempool: check driver enqueue result in one place Date: Sun, 9 Oct 2022 14:11:53 +0300 Message-Id: <20221009111154.213253-1-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220202103354.79832-1-mb@smartsharesystems.com> References: <20220202103354.79832-1-mb@smartsharesystems.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 Enqueue operation must not fail. Move corresponding debug check from one particular case to dequeue operation helper in order to do it for all invocations. Log critical message with useful information instead of rte_panic(). Make rte_mempool_do_generic_put() implementation more readable and fix incosistency when return value is not checked in one place and checked in another. Signed-off-by: Andrew Rybchenko Reviewed-by: Morten Brørup --- lib/mempool/rte_mempool.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h index 4c4af2a8ed..95d64901e5 100644 --- a/lib/mempool/rte_mempool.h +++ b/lib/mempool/rte_mempool.h @@ -786,12 +786,19 @@ rte_mempool_ops_enqueue_bulk(struct rte_mempool *mp, void * const *obj_table, unsigned n) { struct rte_mempool_ops *ops; + int ret; RTE_MEMPOOL_STAT_ADD(mp, put_common_pool_bulk, 1); RTE_MEMPOOL_STAT_ADD(mp, put_common_pool_objs, n); rte_mempool_trace_ops_enqueue_bulk(mp, obj_table, n); ops = rte_mempool_get_ops(mp->ops_index); - return ops->enqueue(mp, obj_table, n); + ret = ops->enqueue(mp, obj_table, n); +#ifdef RTE_LIBRTE_MEMPOOL_DEBUG + if (unlikely(ret < 0)) + RTE_LOG(CRIT, MEMPOOL, "cannot enqueue %u objects to mempool %s\n", + n, mp->name); +#endif + return ret; } /** @@ -1351,12 +1358,7 @@ rte_mempool_do_generic_put(struct rte_mempool *mp, void * const *obj_table, ring_enqueue: /* push remaining objects in ring */ -#ifdef RTE_LIBRTE_MEMPOOL_DEBUG - if (rte_mempool_ops_enqueue_bulk(mp, obj_table, n) < 0) - rte_panic("cannot put objects in mempool\n"); -#else rte_mempool_ops_enqueue_bulk(mp, obj_table, n); -#endif } From patchwork Sun Oct 9 11:11:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 117733 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 3BDEDA0542; Sun, 9 Oct 2022 13:12:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 786F341141; Sun, 9 Oct 2022 13:12:01 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 5D657400D5 for ; Sun, 9 Oct 2022 13:11:59 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 115) id 12D1C7B; Sun, 9 Oct 2022 14:11:59 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mail1.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD autolearn=no autolearn_force=no version=3.4.6 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 28EA769; Sun, 9 Oct 2022 14:11:58 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 28EA769 Authentication-Results: shelob.oktetlabs.ru/28EA769; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Olivier Matz Cc: dev@dpdk.org, =?utf-8?q?Morten_Br=C3=B8rup?= Subject: [PATCH 2/2] mempool: avoid usage of term ring on put Date: Sun, 9 Oct 2022 14:11:54 +0300 Message-Id: <20221009111154.213253-2-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221009111154.213253-1-andrew.rybchenko@oktetlabs.ru> References: <20220202103354.79832-1-mb@smartsharesystems.com> <20221009111154.213253-1-andrew.rybchenko@oktetlabs.ru> 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 Term ring is misleading since it is the default, but still just one of possible drivers to store objects. Signed-off-by: Andrew Rybchenko Reviewed-by: Morten Brørup --- lib/mempool/rte_mempool.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h index 95d64901e5..c2d4e8ba55 100644 --- a/lib/mempool/rte_mempool.h +++ b/lib/mempool/rte_mempool.h @@ -1331,7 +1331,7 @@ rte_mempool_do_generic_put(struct rte_mempool *mp, void * const *obj_table, /* No cache provided or if put would overflow mem allocated for cache */ if (unlikely(cache == NULL || n > RTE_MEMPOOL_CACHE_MAX_SIZE)) - goto ring_enqueue; + goto driver_enqueue; cache_objs = &cache->objs[cache->len]; @@ -1339,7 +1339,7 @@ rte_mempool_do_generic_put(struct rte_mempool *mp, void * const *obj_table, * The cache follows the following algorithm * 1. Add the objects to the cache * 2. Anything greater than the cache min value (if it crosses the - * cache flush threshold) is flushed to the ring. + * cache flush threshold) is flushed to the backend. */ /* Add elements back into the cache */ @@ -1355,9 +1355,9 @@ rte_mempool_do_generic_put(struct rte_mempool *mp, void * const *obj_table, return; -ring_enqueue: +driver_enqueue: - /* push remaining objects in ring */ + /* push objects to the backend */ rte_mempool_ops_enqueue_bulk(mp, obj_table, n); }