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 5B1E443073; Tue, 15 Aug 2023 16:51:04 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1CA324326D; Tue, 15 Aug 2023 16:50:39 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 1CA2243260 for ; Tue, 15 Aug 2023 16:50:36 +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 9B6C36247A; Tue, 15 Aug 2023 14:50:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD147C433C8; Tue, 15 Aug 2023 14:50:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692111035; bh=BT/wIrnsPmQsnhCQmad4ZeSSA7/RGqJvb34EJiS3obo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c5IuYutZLVnlHSToLj5+N5KxEInhSExyD1AlHT3wCymCfEztCaZ9q4kPAszohOyci AAVc/M7ddk953c5SCl3HB5zp9QU9wv8/dLdw++rdGsLoLZ21qp48HRDQhoq7yO3XV5 TjgrXjnVxtRRu63L2WtErIHLFHshMsRaLEmy6cXB0iQNj0zPzNbRqypbwNuIl5dJCe PxPrujhZBUpOOIT2c/3HX7KwQTcAdB3yEedtZ45fLgDk4nLnr3lZnwRC/uOQqs726q qF3CgxQGL3wSeVCPM7NmFpR7B4MYd1wijyt153hNnGUg+BxlB8PG7sSQOiIxLSjmQ/ EaBeT+DBTml9Q== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v4 5/8] memseg: init once Date: Tue, 15 Aug 2023 10:50:20 -0400 Message-Id: <20230815145023.1386003-6-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815145023.1386003-1-okaya@kernel.org> References: <20230815145023.1386003-1-okaya@kernel.org> 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: Sinan Kaya Initialize memory segments just once and bail out if called multiple times. Signed-off-by: Sinan Kaya --- lib/eal/linux/eal_memory.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/eal/linux/eal_memory.c b/lib/eal/linux/eal_memory.c index 9b6f08fba8..df0aa9ccc7 100644 --- a/lib/eal/linux/eal_memory.c +++ b/lib/eal/linux/eal_memory.c @@ -57,6 +57,7 @@ */ static int phys_addrs_available = -1; +static bool memseg_initialized; #define RANDOMIZE_VA_SPACE_FILE "/proc/sys/kernel/randomize_va_space" @@ -1920,6 +1921,10 @@ rte_eal_memseg_init(void) { /* increase rlimit to maximum */ struct rlimit lim; + int ret; + + if (memseg_initialized) + return 0; #ifndef RTE_EAL_NUMA_AWARE_HUGEPAGES const struct internal_config *internal_conf = @@ -1948,11 +1953,16 @@ rte_eal_memseg_init(void) } #endif - return rte_eal_process_type() == RTE_PROC_PRIMARY ? + ret = rte_eal_process_type() == RTE_PROC_PRIMARY ? #ifndef RTE_ARCH_64 memseg_primary_init_32() : #else memseg_primary_init() : #endif memseg_secondary_init(); + + if (!ret) + memseg_initialized = true; + + return ret; } -- 2.25.1