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 02F6643081; Wed, 16 Aug 2023 17:35:34 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E4A8F4324F; Wed, 16 Aug 2023 17:35:33 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id 318E64003C; Wed, 16 Aug 2023 17:35:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692200132; x=1723736132; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+AyIjOXduHBzG5WxGVrasRlFgrXwzlKwK56VeX8q4Ws=; b=L+B/C2t8g7qK1OvghmgK62LbT4r8EKgxNaiQRV0V7pbaM4FXKI6GBcM+ JaBEqQNcVUlasC+3K6S43FT7VQh6L7qKWSaTDe4rU/h0nqnH9mkRzVn+2 NDlU9BNGWnZ2++Hf/zp85Q6g32rzG3eehETLFyjHL63RRVr0b7CJ5UHA1 NAInn8EeyZoBB+3wgKilDDjRoi6gDnjwtB6/zcnD9jxLNO0k82S/5P+RP qqKalT+aMR8yBaTIViIPKAXgGmuc7tV/H2oGiDlNf+VFN5CqkSjNuKfwq IWJCiG7o9xN7O/hIU/YFKyK9SnRvkjpqHgScRkLdktPK0xG4edjmO15Kb g==; X-IronPort-AV: E=McAfee;i="6600,9927,10803"; a="458915935" X-IronPort-AV: E=Sophos;i="6.01,177,1684825200"; d="scan'208";a="458915935" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2023 08:35:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10803"; a="857856212" X-IronPort-AV: E=Sophos;i="6.01,177,1684825200"; d="scan'208";a="857856212" Received: from silpixa00401385.ir.intel.com ([10.237.214.14]) by orsmga004.jf.intel.com with ESMTP; 16 Aug 2023 08:35:29 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: david.marchand@redhat.com, probb@iol.unh.edu, mb@smartsharesystems.com, stable@dpdk.org, Bruce Richardson Subject: [PATCH v6 01/11] mempool: fix default ops for an empty mempool Date: Wed, 16 Aug 2023 16:34:29 +0100 Message-Id: <20230816153439.551501-2-bruce.richardson@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230816153439.551501-1-bruce.richardson@intel.com> References: <20230721115125.55137-1-bruce.richardson@intel.com> <20230816153439.551501-1-bruce.richardson@intel.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 From: David Marchand An empty mempool's ops were not initialised to a default value wrt to what the application requested via the flags parameter. As rte_mempool_create() relies on rte_mempool_create_empty(), simply move this ops initialisation to rte_mempool_create_empty(). Fixes: aa10457eb4c2 ("mempool: make mempool populate and free api public") Cc: stable@dpdk.org Signed-off-by: David Marchand Reviewed-by: Bruce Richardson --- lib/mempool/rte_mempool.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c index 4d337fca8d..7a7a9bf6db 100644 --- a/lib/mempool/rte_mempool.c +++ b/lib/mempool/rte_mempool.c @@ -914,6 +914,22 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, STAILQ_INIT(&mp->elt_list); STAILQ_INIT(&mp->mem_list); + /* + * Since we have 4 combinations of the SP/SC/MP/MC examine the flags to + * set the correct index into the table of ops structs. + */ + if ((flags & RTE_MEMPOOL_F_SP_PUT) && (flags & RTE_MEMPOOL_F_SC_GET)) + ret = rte_mempool_set_ops_byname(mp, "ring_sp_sc", NULL); + else if (flags & RTE_MEMPOOL_F_SP_PUT) + ret = rte_mempool_set_ops_byname(mp, "ring_sp_mc", NULL); + else if (flags & RTE_MEMPOOL_F_SC_GET) + ret = rte_mempool_set_ops_byname(mp, "ring_mp_sc", NULL); + else + ret = rte_mempool_set_ops_byname(mp, "ring_mp_mc", NULL); + + if (ret) + goto exit_unlock; + /* * local_cache pointer is set even if cache_size is zero. * The local_cache points to just past the elt_pa[] array. @@ -954,7 +970,6 @@ rte_mempool_create(const char *name, unsigned n, unsigned elt_size, rte_mempool_obj_cb_t *obj_init, void *obj_init_arg, int socket_id, unsigned flags) { - int ret; struct rte_mempool *mp; mp = rte_mempool_create_empty(name, n, elt_size, cache_size, @@ -962,22 +977,6 @@ rte_mempool_create(const char *name, unsigned n, unsigned elt_size, if (mp == NULL) return NULL; - /* - * Since we have 4 combinations of the SP/SC/MP/MC examine the flags to - * set the correct index into the table of ops structs. - */ - if ((flags & RTE_MEMPOOL_F_SP_PUT) && (flags & RTE_MEMPOOL_F_SC_GET)) - ret = rte_mempool_set_ops_byname(mp, "ring_sp_sc", NULL); - else if (flags & RTE_MEMPOOL_F_SP_PUT) - ret = rte_mempool_set_ops_byname(mp, "ring_sp_mc", NULL); - else if (flags & RTE_MEMPOOL_F_SC_GET) - ret = rte_mempool_set_ops_byname(mp, "ring_mp_sc", NULL); - else - ret = rte_mempool_set_ops_byname(mp, "ring_mp_mc", NULL); - - if (ret) - goto fail; - /* call the mempool priv initializer */ if (mp_init) mp_init(mp, mp_init_arg); -- 2.39.2