From patchwork Tue Aug 15 03:13:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130316 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 08F0743069; Tue, 15 Aug 2023 05:13:30 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 39E304326B; Tue, 15 Aug 2023 05:13:17 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 4D0C441104 for ; Tue, 15 Aug 2023 05:13:14 +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 BB7AF618CD; Tue, 15 Aug 2023 03:13:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0655C433CA; Tue, 15 Aug 2023 03:13:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692069193; bh=lUVb8U2/URRR99Mo1M8wdnr91IxFL31LQZyYe+CgHj4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kvc++zjzixFAmL4otGX7FzwkQsDkXcqow+30CTjs+MdZopWd/99jeEJF9ulBZIhBF k+r99tbNoyekrknrCuPzRSSZHOgbx6+FBHC+cIskz5aPD+Czzqv6SAoKB8h2pYJm6u 1Ig8I7/swC+UiM2m8sIZvFKY05yV1dnHw9jvM756VNgOuIVjCAmrFGDJfNmpVAsFqy esrIEnW4wxwsLYcPnYtpMrK90wI/N0BQViqY5hMONouVsoxFTkkMg4vLn3lKkZ0Cu1 tBVtUxdYoHUVXiqU+lmQQKkFoGtnbAW/QiHWhe7qxFIywbHebpDj+E/avdMUpmf1Eg /mrMBfoMbZ7Mg== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v2 3/7] eal_memzone: bail out on initialized Date: Mon, 14 Aug 2023 23:13:03 -0400 Message-Id: <20230815031307.1299726-4-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815031307.1299726-1-okaya@kernel.org> References: <20230815031307.1299726-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 930fee5fdc..3a10aa02dd 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; + static inline const struct rte_memzone * memzone_lookup_thread_unsafe(const char *name) { @@ -397,6 +399,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; @@ -415,6 +420,8 @@ rte_eal_memzone_init(void) rte_rwlock_write_unlock(&mcfg->mlock); + memzone_initialized = true; + return ret; }