From patchwork Tue Aug 15 03:52:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130323 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 4784C43069; Tue, 15 Aug 2023 05:53:06 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EFA864325E; Tue, 15 Aug 2023 05:52:52 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 95D2543000 for ; Tue, 15 Aug 2023 05:52:50 +0200 (CEST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2164C62638; Tue, 15 Aug 2023 03:52:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C686BC433C9; Tue, 15 Aug 2023 03:52:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692071569; bh=joa54IhMnxETGrrAfoMJz218LI2OKvqtobhOYXCZW5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qp/UXDTAXUjLMejIzobNSQrVvfRrP61E8MNlAMQMFX+O/db8tKD0Thsju3lVSwxn7 psNhDrrffomxL7mjgEcpXNFGZxlKzGiJW6eWHQQ7EgVzRMXvku9Qw/Kxb9dz0fTRB6 fdKcyVILPo6nqpGx2AdSCqjNjG+yvIUO1e+GEbCGWs8Ds4mRX0IWNs5Z3rHHA4+snD mgOFo/iqeygJGSGZDRhvqBXsbfvTCGOhxv4W4bfduOy5Vyy6L94nNVozk3lGz2frJu pgaL5pJ/CKPdLtDCrFOD3EQvpVeTnwAvHTTjkKJND5PvxBtUgrAtAukaOVfAo04LRB 7EboHuB8yQ1pQ== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v3 3/7] eal_memzone: bail out on initialized Date: Mon, 14 Aug 2023 23:52:35 -0400 Message-Id: <20230815035239.1365591-4-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815035239.1365591-1-okaya@kernel.org> References: <20230815035239.1365591-1-okaya@kernel.org> 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 From: Sinan Kaya Initialize memzone once and bail out if someone calls init multiple times. Signed-off-by: Sinan Kaya --- lib/eal/common/eal_common_memzone.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/eal/common/eal_common_memzone.c b/lib/eal/common/eal_common_memzone.c index 1f3e701499..6645ccfe83 100644 --- a/lib/eal/common/eal_common_memzone.c +++ b/lib/eal/common/eal_common_memzone.c @@ -22,6 +22,8 @@ #include "eal_private.h" #include "eal_memcfg.h" +static bool memzone_initialized; + /* Default count used until rte_memzone_max_set() is called */ #define DEFAULT_MAX_MEMZONE_COUNT 2560 @@ -426,6 +428,9 @@ rte_eal_memzone_init(void) struct rte_mem_config *mcfg; int ret = 0; + if (memzone_initialized) + return 0; + /* get pointer to global configuration */ mcfg = rte_eal_get_configuration()->mem_config; @@ -444,6 +449,8 @@ rte_eal_memzone_init(void) rte_rwlock_write_unlock(&mcfg->mlock); + memzone_initialized = true; + return ret; }